graphql-type-uuid
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/graphql-type-uuid package

0.2.0 • Public • Published

graphql-type-uuid npm

UUID scalar type for GraphQL.js.

Travis Codecov

Usage

This package exports a UUID scalar GraphQL.js type:

import GraphQLUUID from 'graphql-type-uuid';

Programmatically-constructed schemas

You can use this in a programmatically-constructed schema as with any other scalar type:

import { GraphQLObjectType } from 'graphql';
import GraphQLUUID from 'graphql-type-uuid';
 
export default new GraphQLObjectType({
  name: 'MyType',
  fields: {
    myField: { type: GraphQLUUID },
  },
});

SDL with graphql-tools

When using the SDL with graphql-tools, define GraphQLUUID as the resolver for the corresponding scalar type in your schema:

import { makeExecutableSchema } from 'graphql-tools';
import GraphQLUUID from 'graphql-type-uuid';
 
const typeDefs = `
scalar UUID
 
type MyType {
  myField: UUID
}
`;
 
const resolvers = {
  UUID: GraphQLUUID,
};
 
export default makeExecutableSchema({ typeDefs, resolvers });

Related

If you happen to be looking for a JSON scalar GraphQL.js type, please check graphql-type-json, in which this project is heavily inspired.

Readme

Keywords

Package Sidebar

Install

npm i graphql-type-uuid

Weekly Downloads

3,312

Version

0.2.0

License

MIT

Unpacked Size

14.6 kB

Total Files

10

Last publish

Collaborators

  • olistic