graphql-base64
v1.0.2
Published
Partial modified fork of graphql-relay's globalId feature.
Downloads
71
Readme
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.