express-graphql

  • Version 0.12.0
  • Published
  • 1.01 MB
  • 4 dependencies
  • MIT license

Install

npm i express-graphql
yarn add express-graphql
pnpm add express-graphql

Overview

Production ready GraphQL HTTP middleware.

Index

Functions

function getGraphQLParams

getGraphQLParams: (request: Request) => Promise<GraphQLParams>;
  • Provided a "Request" provided by express or connect (typically a node style HTTPClientRequest), Promise the GraphQL request parameters.

function graphqlHTTP

graphqlHTTP: (options: Options) => Middleware;
  • Middleware for express; takes an options object or function as input to configure behavior, and returns an express middleware.

Interfaces

interface GraphQLParams

interface GraphQLParams {}

    property operationName

    operationName: string | null;

      property query

      query: string | null;

        property raw

        raw: boolean;

          property variables

          variables: {
          readonly [name: string]: unknown;
          } | null;

            interface OptionsData

            interface OptionsData {}

              property context

              context?: unknown;
              • A value to pass as the context to this middleware.

              property customExecuteFn

              customExecuteFn?: (args: ExecutionArgs) => MaybePromise<ExecutionResult>;
              • An optional function which will be used to execute instead of default execute from graphql-js.

              property customFormatErrorFn

              customFormatErrorFn?: (error: GraphQLError) => GraphQLFormattedError;
              • An optional function which will be used to format any errors produced by fulfilling a GraphQL operation. If no function is provided, GraphQL's default spec-compliant formatError function will be used.

              property customParseFn

              customParseFn?: (source: Source) => DocumentNode;
              • An optional function which will be used to create a document instead of the default parse from graphql-js.

              property customValidateFn

              customValidateFn?: (
              schema: GraphQLSchema,
              documentAST: DocumentNode,
              rules: ReadonlyArray<ValidationRule>
              ) => ReadonlyArray<GraphQLError>;
              • An optional function which will be used to validate instead of default validate from graphql-js.

              property extensions

              extensions?: (info: RequestInfo) => MaybePromise<
              | undefined
              | {
              [key: string]: unknown;
              }
              >;
              • An optional function for adding additional metadata to the GraphQL response as a key-value object. The result will be added to "extensions" field in the resulting JSON. This is often a useful place to add development time info such as the runtime of a query or the amount of resources consumed.

                Information about the request is provided to be used.

                This function may be async.

              property fieldResolver

              fieldResolver?: GraphQLFieldResolver<unknown, unknown>;
              • A resolver function to use when one is not provided by the schema. If not provided, the default field resolver is used (which looks for a value or method on the source value with the field's name).

              property formatError

              formatError?: (error: GraphQLError) => GraphQLFormattedError;
              • formatError is deprecated and replaced by customFormatErrorFn. It will be removed in version 1.0.0.

              property graphiql

              graphiql?: boolean | GraphiQLOptions;
              • A boolean to optionally enable GraphiQL mode. Alternatively, instead of true you can pass in an options object.

              property pretty

              pretty?: boolean;
              • A boolean to configure whether the output should be pretty-printed.

              property rootValue

              rootValue?: unknown;
              • An object to pass as the rootValue to the graphql() function.

              property schema

              schema: GraphQLSchema;
              • A GraphQL schema from graphql-js.

              property typeResolver

              typeResolver?: GraphQLTypeResolver<unknown, unknown>;
              • A type resolver function to use when none is provided by the schema. If not provided, the default type resolver is used (which looks for a __typename field or alternatively calls the isTypeOf method).

              property validationRules

              validationRules?: ReadonlyArray<(ctx: ValidationContext) => ASTVisitor>;
              • An optional array of validation rules that will be applied on the document in additional to those defined by the GraphQL spec.

              interface RequestInfo

              interface RequestInfo {}
              • All information about a GraphQL request.

              property context

              context?: unknown;
              • A value to pass as the context to the graphql() function.

              property document

              document: DocumentNode;
              • The parsed GraphQL document.

              property operationName

              operationName: string | null;
              • The (optional) operation name requested.

              property result

              result: FormattedExecutionResult;
              • The result of executing the operation.

              property variables

              variables: {
              readonly [name: string]: unknown;
              } | null;
              • The variable values used at runtime.

              Type Aliases

              type Options

              type Options =
              | ((
              request: Request,
              response: Response,
              params?: GraphQLParams
              ) => MaybePromise<OptionsData>)
              | MaybePromise<OptionsData>;
              • Used to configure the graphqlHTTP middleware by providing a schema and other configuration options.

                Options can be provided as an Object, a Promise for an Object, or a Function that returns an Object or a Promise for an Object.

              Package Files (1)

              Dependencies (4)

              Dev Dependencies (0)

              No dev dependencies.

              Peer Dependencies (1)

              Badge

              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/express-graphql.

              • Markdown
                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/express-graphql)
              • HTML
                <a href="https://www.jsdocs.io/package/express-graphql"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>