Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 1.15 KB

File metadata and controls

43 lines (31 loc) · 1.15 KB

graphql-middleware-forward-binding

CircleCI npm version

GraphQL Middleware plugin for forwarding request to GraphQL Bindings.

Usage

With GraphQL Yoga and Prisma

import { GraphQLServer } from 'graphql-yoga'
import { forward } from 'graphql-middleware-forward-binding'
import { Prisma } from 'prisma-binding'

const bindingForwardMiddleware = forward('Query', 'Mutation.createBasket')('db')

const server = GraphQLServer({
  typeDefs: 'generated-schema.graphql',
  resolvers: {},
  middlewares: [bindingForwardMiddleware],
  context: req => ({
    ...req,
    db: new Prisma({
      endpoint: 'https://eu1.prisma.sh/public-saberbow/prisma-yoga/dev',
      debug: true,
    }),
  }),
})

serve.start(() => `Server running on http://localhost:4000`)

API

function forward(types: string[])(database: string): IMiddleware

License

MIT @ Matic Zavadlal