graphql-base64

1.0.2 • Public • Published

graphql-base64

Turn IDs into opaque identifiers for GraphQL.

Encode and decode IDs in Base64. Partial fork of graphql-relay-js with slight changes. It does not rely node's internal Buffer when encoding/decoding in Base64.

Install

$ yarn add graphql-base64

Usage

Example:

import { globalIdField } from 'graphql-base64';

export const userType = new GraphQLObjectType({
  name: 'User',
  fields: () => ({
    id: globalIdField(),
  }),
});

API

globalIdField()

Returns configuration for the id field of an object.

toGlobalId(type, id)

Encode a type name and ID in Base64.

fromGlobalId(string)

Decode a global ID from Base64 and return it's type name and ID.

Related

Readme

Keywords

Package Sidebar

Install

npm i graphql-base64

Weekly Downloads

5

Version

1.0.2

License

MIT

Last publish

Collaborators

  • nijynot