GraphQL integration

Foxx bundles version 0.6 of the
graphql-sync module, which is a
synchronous wrapper for the official JavaScript GraphQL reference
implementation, to allow writing GraphQL schemas directly inside Foxx.

Additionally the @arangodb/foxx/graphql lets you create routers for serving
GraphQL requests, which closely mimicks the behavior of the
express-graphql module.

For more information on graphql-sync see the
graphql-js API reference
(note that graphql-sync never wraps results in promises).

For an example of a GraphQL schema in Foxx that resolves fields using the
database see the GraphQL example service
(also available from the Foxx store).

Examples

constgraphql=require('graphql-sync');constgraphqlSchema=newgraphql.GraphQLSchema({// ...});// Mounting a graphql endpoint directly in a service:module.context.use('/graphql',createGraphQLRouter({schema:graphqlSchema,graphiql:true}));// Or at the service's root URL:module.context.use(createGraphQLRouter({schema:graphqlSchema,graphiql:true}));// Or inside an existing router:router.get('/hello',function(req,res){res.write('Hello world!');});router.use('/graphql',createGraphQLRouter({schema:graphqlSchema,graphiql:true}));

Note: ArangoDB aims for stability which means bundled dependencies will
generally not be updated as quickly as their maintainers make updates
available on GitHub or NPM. Starting with ArangoDB 3.2, if you want to use a
newer version than the one bundled with your target version of ArangoDB, you
can provide your own version of the library by passing it via the graphql option: