lucalas / graphql-type-object-id

GraphQL type for MongoDB ObjectId with validation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

built with typescript-lib-starter

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

About

GraphQL type for MongoDB ObjectId with validation.

License:MIT License


Languages

Language:TypeScript 91.8%Language:JavaScript 8.2%