Skip to content
This repository has been archived by the owner on Aug 10, 2019. It is now read-only.

Converts a Mongoose schema to its GraphQL representation.

License

Notifications You must be signed in to change notification settings

fabiospampinato/mongoose-to-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Converts a Mongoose schema to its GraphQL representation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published