graphql-type-object-id
v1.0.0
Published
A graphql scalar type for MongoDB ObjectId.
Downloads
5,178
Readme
graphql-type-object-id
MongoDB ObjectId scalar type for GraphQL.js.
## Installation
$ npm i graphql-type-object-id
Or
$ yarn add graphql-type-object-id
Usage
Import the type:
import GraphQLObjectId from 'graphql-type-object-id';
Or
import { GraphQLObjectId } from 'graphql-type-object-id';
In your schema
You can use this in a programmatically-constructed schema as with any other scalar type:
import { makeExecutableSchema } from '@graphql-tools/schema';
import GraphQLObjectId from 'graphql-type-object-id';
const typeDefs = `
scalar ObjectId
# ...
`;
const resolvers = {
ObjectId: GraphQLObjectId,
};
export default makeExecutableSchema({ typeDefs, resolvers });
License
MIT