GQLExpressMiddleware

GQLExpressMiddleware

new GQLExpressMiddleware()

A handler that exposes an express middleware function that mounts a
GraphQL I/O endpoint. Typical usage follows:

const app = express();
app.use(/.../, new GQLExpressMiddleware([...classes]).middleware);
Source:
GQLExpressMiddleware.js, line 74

Classes

⎆⠀constructor

Methods

⌾⠀customMiddleware([graphqlHttpOptions={graphiql: true}], patchFinalOpts) → {function}

If your needs require you to specify different values to graphqlHTTP,
part of the express-graphql package, you can use the customMiddleware
function to do so.

The first parameter is an object that should contain valid graphqlHTTP
options. See https://github.com/graphql/express-graphql#options for more
details. Validation is NOT performed.

The second parameter is a function that will be called after any options
have been applied from the first parameter and the rest of the middleware
has been performed. This, if not modified, will be the final options
passed into graphqlHTTP. In your callback, it is expected that the
supplied object is to be modified and THEN RETURNED. Whatever is returned
will be used or passed on. If nothing is returned, the options supplied
to the function will be used instead.

Parameters:
Name Type Attributes Default Description
[graphqlHttpOptions={graphiql: true}] Object optional
{graphiql: true}

standard set of
express-graphql options. See above.

patchFinalOpts function

see above

Returns:
( function )

a middleware function compatible with Express

Source:
GQLExpressMiddleware.js, line 298

⌾⠀injectComments(schema)

Until such time as I can get the reference Facebook GraphQL AST parser to
read and apply descriptions or until such time as I employ the Apollo
AST parser, providing a static get apiDocs() getter is the way to get
your descriptions into the proper fields, post schema creation.

This method walks the types in the registered handlers and the supplied
schema type. It then injects the written comments such that they can
be exposed in graphiql and to applications or code that read the meta
fields of a built schema

TODO handle argument comments and other outliers

Parameters:
Name Type Description
schema Object

a built GraphQLSchema object created via buildSchema
or some other alternative but compatible manner

Source:
GQLExpressMiddleware.js, line 389

⌾⠀injectInterfaceResolvers(schema)

Somewhat like injectComments and other similar methods, the
injectInterfaceResolvers method walks the registered handlers and
finds GQLInterface types and applies their resolveType()
implementations.

Parameters:
Name Type Description
schema Object

a built GraphQLSchema object created via buildSchema
or some other alternative but compatible manner

Source:
GQLExpressMiddleware.js, line 527

⌾⠀makeRoot(req, res, gql) → {Promise.<Object>}

An asynchronous function used to parse the supplied classes for each
ones resolvers and mutators. These are all combined into a single root
object passed to express-graphql.

Parameters:
Name Type Description
req Request

an Express 4.x request object

res Response

an Express 4.x response object

gql Object

an object containing information about the graphql
request. It has the format of { query, variables, operationName, raw }
as described here: https://github.com/graphql/express-graphql

Returns:
( Promise.<Object> )

a Promise resolving to an Object containing all
the functions described in both Query and Mutation types.

Source:
GQLExpressMiddleware.js, line 111

⌾⠀makeSchema() → {string}

A function that combines the IDL schemas of all the supplied classes and
returns that value to the middleware getter.

Returns:
( string )

a dynamically generated GraphQL IDL schema string

Source:
GQLExpressMiddleware.js, line 226

⬇︎⠀middleware() → {function}

Using the express-graphql module, it returns an Express 4.x middleware
function.

Returns:
( function )

a function that expects request, response and next
parameters as all Express middleware functions.

Source:
GQLExpressMiddleware.js, line 282

⬇︎⠀middlewareWithoutGraphiQL() → {function}

Using the express-graphql module, it returns an Express 4.x middleware
function. This version however, has graphiql disabled. Otherwise it is
identical to the middleware property

Returns:
( function )

a function that expects request, response and next
parameters as all Express middleware functions.

Source:
GQLExpressMiddleware.js, line 578