graphql-objectid-scalar
v1.0.5
Published
MongoDB objectId scalar for GraphQL.js
Downloads
1,869
Readme
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 });