@sherbst/mongoose-to-graphql
TypeScript icon, indicating that this package has built-in type declarations

1.0.10 • Public • Published

Mongoose to Graphql

Converts a Mongoose schema to its GraphQL representation.

Install

$ npm install --save mongoose-to-graphql

Usage

import MongooseToGraphql from 'mongoose-to-graphql';

MongooseToGraphql.type ({
  type: [String],
  required: true
}); // [String]!

MongooseToGraphql ( 'Book', {
  title: String,
  category: Number
}); // type Book {
    //   title: String
    //   category: Float
    // }

API

MongooseToGraphQL ( ...args )

Calls .schema with ...args.

.schema ( name: string, schema: {} | mongoose.Schema ): string

Converts an object or a Mongoose schema to its GraphQL string representation.

.model ( model: Function ): string

Converts a Mongoose model to its GraphQL string representation.

.plainObject ( obj: {} ): string

Converts a plain object to its GraphQL string representation.

.type ( type: any ): string

Converts a supported type to its GraphQL string representation, or throws an error.

Related

  • mongease - Tiny wrapper around Mongoose for easier creation of schemas and models. Supports plugins.
  • mongease-graphql - Mongease plugin for adding support to GraphQL schemas creation.
  • mongease-graphql-builder - Module for auto-generating simple GraphQL queries from Mongease descriptions.

License

MIT © Fabio Spampinato

Package Sidebar

Install

npm i @sherbst/mongoose-to-graphql

Weekly Downloads

1

Version

1.0.10

License

MIT

Unpacked Size

20.3 kB

Total Files

12

Last publish

Collaborators

  • sherbst