DEPRECATED
This project has been renamed to graphql-resolved.
Install using npm install graphql-resolved
instead.
graphql-resolvers-chain
graphql-resolvers-chain
is a framework/server agnostic resolvers creation tool for GraphQL
This project provide a middleware-like approach to GraphQL servers enabling the composition of resolvers chains through a simple and expressive API.
Installing
npm
npm i graphql-resolvers-chain --save
yarn
yarn add graphql-resolvers-chain
Usage
chain
, protect
or apply
api
Create your first resolver using the chain
api
Create a new resolver chaining the ones in the supplied array. The order matters from left to right.
The last resolver being the one return the final expect value.
chain([1, 2, 3, 4])
;;; const getMe = const Query = getMe const resolvers = Query
apply
api
Applies all the resolvers
to all of those in the to
object.
resolvers
(The order matters from left to right)
const allUserResolvers = const Query = ...allUserResolvers
protect
api
The protect key work take three arguments:
it
(Optional) a resolver function, if suppliedprotect
returns a new resolver functionall
(Optional) an object with resolvers, if suppliedprotect
returns an object with the exact same resolvers names as keysusing
a list of resolvers to apply(The order matters from left to right).
const getMe = ; const adminResolvers = ; const Query = getMe ...adminResolvers