GraphQL

Build high-level endpoints for your API consumers.

/* @runkit */
// register extension
Grown.use(require('@grown/graphql'));

// ./index.gql
// type Mutation { noop: Int }
// type Query { truth: Int }

// ./handlers/Test/Query/truth/index.js
// module.exports = function () {
//   return 42;
// };

// mount our GraphQL API
server.mount('/', Grown.GraphQL
  .setup([`${__dirname}/index.gql`],
    Grown.load(`${__dirname}/handlers`)));

Click ► RUN and then ask with your GraphQL client: query { truth } — or try requesting through this link.

Public methods static

  • setup(schemas, container) — Returns a middleware ready to be mounted into the server instance. Given schemas are expected to be an array of *.gql files and container is the implementation.

Private* methods static

  • _startGraphQLServer(typeDefs, resolvers) — Used by setup() to build the GraphQL middleware.
  • _bindGraphQLServer(schemas, container) — Used by setup() to decorate the given handlers.

➯ Next: Extensions ⟩ GRPC