mongease-graphql-builder
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

Mongease Graphql Builder

Module for auto-generating simple GraphQL queries from Mongease descriptions.

Install

$ npm install --save mongease-graphql-builder

Usage

import Mongease from 'mongease';
import MongeaseGraphQL from 'mongease-graphql';
import Builder from 'mongease-graphql-builder';
 
Mongease.plugin ( MongeaseGraphQL.make );
 
Mongease.make ( 'Book', {
  schema: {
    title: String,
    category: Number,
    read: Boolean
  },
  resolvers: {
    Query: {
      findBooks () {}
    },
    Mutation: {
      bookMarkAsRead () {}
    }
  }
});
 
Builder.query ( 'findBooks', true ); // GraphQL query as string
Builder.mutation ( 'bookMarkAsRead' ) // GraphQL-ready mutation

API

.query ( resolver: string, string = false )

Creates and returns a GraphQL query, given the name of the resolver.

.mutation ( resolver: string, string = false )

Creates and returns a GraphQL mutation, given the name of the resolver.

.subscription ( resolver: string, string = false )

Creates and returns a GraphQL subscription, given the name of the resolver.

Related

  • mongoose-to-graphql - Converts a Mongoose schema to its GraphQL representation.
  • 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.

License

MIT © Fabio Spampinato

Dependencies (5)

Dev Dependencies (3)

Package Sidebar

Install

npm i mongease-graphql-builder

Weekly Downloads

1

Version

1.0.6

License

MIT

Unpacked Size

19.1 kB

Total Files

8

Last publish

Collaborators

  • fabiospampinato