Nanoscale Parts Manufacturing
Wondering what’s next for npm?Check out our public roadmap! »

@kiwicom/graphql-global-id

0.4.1 • Public • Published

Usage

This utility automatically creates correct opaque and globally unique ID type so you don't have to think about it.

import GlobalID from '@kiwicom/graphql-global-id';
 
export default new GraphQLObjectType({
  name: 'TypeName',
  fields: {
    id: GlobalID(({ id }) => id),
  },
});

The example above would create this type:

type TypeName {
  """
  The globally unique ID of an object. You can unmask this ID to get original
  value but please note that this unmasked ID is not globally unique anymore and
  therefore it cannot be used as a cache key.
  """
  id(opaque: Boolean = true): ID!
}

You can easily access original ID (also known as "database ID" or "original ID") using opaque parameter. This is very handy for legacy applications. However, try to always prefer the opaque version.

Keywords

none

Install

npm i @kiwicom/[email protected]

Version

0.4.1

License

MIT

Unpacked Size

9.91 kB

Total Files

6

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar