0.2.1 • Published 6 years ago

graphql-prefab-resolvers v0.2.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

graphql-prefab-resolvers

Reduce resolver boilerplate by configuring resolvers through JSON

Installation

yarn add graphql-prefab-resolvers

Usage

import { compile } from 'graphql-prefab-resolvers'
import { addResolveFunctionsToSchema } from 'graphql-tools'

...

const resolversPath = path.resolve(__dirname, './resolvers')
addResolveFunctionsToSchema(schema, compile(resolversPath))

Adding custom resolvers

Basic Example:

import { addResolver } from 'graphql-prefab-resolvers'

const fooResolver = (options) => (obj, args, context, info) => 'foo'

addResolver('foo', fooResolver)

Demo

Take a look at the demo server to see just how easy setting up GraphQL using graphql-prefab-resolvers can be.

yarn demo