A graphql scalar type for MongoDB ObjectId.
npm install graphql-type-object-id
MongoDB ObjectId scalar type for GraphQL.js.
## Installation
``bash`
$ npm i graphql-type-object-id
Or
`bash`
$ yarn add graphql-type-object-idUsage
Import the type:
`js`
import GraphQLObjectId from 'graphql-type-object-id';
Or
`js`
import { GraphQLObjectId } from 'graphql-type-object-id';
You can use this in a programmatically-constructed schema as with any other scalar type:
`js
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 });
``
MIT