Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 1.18 KB

README.md

File metadata and controls

44 lines (30 loc) · 1.18 KB

CircleCI npm version install size

graphql-objectid-scalar

Usage

Install it with

npm install graphql-objectid-scalar

This package exports a mongodb GraphQLObjectId scalar :

import { GraphQLObjectId } from "graphql-objectid-scalar";

SDL with GraphQL-tools

When using the SDL with GraphQL-tools, define GraphQLObjectId as the resolver for the appropriate scalar type in your schema:

import { makeExecutableSchema } from "graphql-tools";
import { GraphQLObjectId } from "graphql-objectid-scalar";

const typeDefs = `
scalar GraphQLObjectId

type MyType {
  _id: GraphQLObjectId
}

# ...
`;

const resolvers = {
    GraphQLObjectId: GraphQLObjectId
};

export default makeExecutableSchema({ typeDefs, resolvers });