apollo-server-core

  • Version 3.3.0
  • Published
  • 1.28 MB
  • 21 dependencies
  • MIT license

Install

npm i apollo-server-core
yarn add apollo-server-core
pnpm add apollo-server-core

Overview

Core engine for Apollo GraphQL server

Index

Functions

Classes

Interfaces

Type Aliases

Functions

function ApolloServerPluginCacheControl

ApolloServerPluginCacheControl: (
options?: ApolloServerPluginCacheControlOptions
) => any;

    function ApolloServerPluginCacheControlDisabled

    ApolloServerPluginCacheControlDisabled: () => any;

      function ApolloServerPluginDrainHttpServer

      ApolloServerPluginDrainHttpServer: (
      options: ApolloServerPluginDrainHttpServerOptions
      ) => any;

        function ApolloServerPluginInlineTrace

        ApolloServerPluginInlineTrace: (
        options?: ApolloServerPluginInlineTraceOptions
        ) => any;

          function ApolloServerPluginInlineTraceDisabled

          ApolloServerPluginInlineTraceDisabled: () => any;

            function ApolloServerPluginLandingPageDisabled

            ApolloServerPluginLandingPageDisabled: () => any;

              function ApolloServerPluginLandingPageGraphQLPlayground

              ApolloServerPluginLandingPageGraphQLPlayground: (
              options?: ApolloServerPluginLandingPageGraphQLPlaygroundOptions
              ) => any;

                function ApolloServerPluginLandingPageLocalDefault

                ApolloServerPluginLandingPageLocalDefault: (
                options?: ApolloServerPluginLandingPageLocalDefaultOptions
                ) => any;

                  function ApolloServerPluginLandingPageProductionDefault

                  ApolloServerPluginLandingPageProductionDefault: (
                  options?: ApolloServerPluginLandingPageProductionDefaultOptions
                  ) => any;

                    function ApolloServerPluginSchemaReporting

                    ApolloServerPluginSchemaReporting: (
                    options?: ApolloServerPluginSchemaReportingOptions
                    ) => any;

                      function ApolloServerPluginUsageReporting

                      ApolloServerPluginUsageReporting: <TContext>(
                      options?: ApolloServerPluginUsageReportingOptions<TContext>
                      ) => any;

                        function ApolloServerPluginUsageReportingDisabled

                        ApolloServerPluginUsageReportingDisabled: () => any;

                          function convertNodeHttpToRequest

                          convertNodeHttpToRequest: (req: any) => any;

                            function gql

                            gql: (template: TemplateStringsArray | string, ...substitutions: any[]) => any;

                              function resolveGraphqlOptions

                              resolveGraphqlOptions: (
                              options:
                              | GraphQLServerOptions<Record<string, any>, any>
                              | ((...args: Array<any>) => any),
                              ...args: Array<any>
                              ) => Promise<GraphQLServerOptions>;

                                function runHttpQuery

                                runHttpQuery: (
                                handlerArguments: Array<any>,
                                request: HttpQueryRequest
                                ) => Promise<HttpQueryResponse>;

                                  Classes

                                  class ApolloServerBase

                                  class ApolloServerBase<ContextFunctionParams = any> {}

                                    constructor

                                    constructor(config: Config<ContextFunctionParams>);

                                      property graphqlPath

                                      graphqlPath: string;

                                        property plugins

                                        protected plugins: any[];

                                          property requestOptions

                                          requestOptions: Partial<GraphQLServerOptions<any, any>>;

                                            method assertStarted

                                            protected assertStarted: (methodName: string) => void;

                                              method ensureStarted

                                              protected ensureStarted: () => Promise<void>;

                                                method executeOperation

                                                executeOperation: (
                                                request: Omit<GraphQLRequest, 'query'> & { query?: string | DocumentNode },
                                                integrationContextArgument?: ContextFunctionParams
                                                ) => Promise<import('apollo-server-types').GraphQLResponse>;

                                                  method getLandingPage

                                                  protected getLandingPage: () => LandingPage | null;

                                                    method graphQLServerOptions

                                                    protected graphQLServerOptions: (
                                                    integrationContextArgument?: any
                                                    ) => Promise<GraphQLServerOptions>;

                                                      method serverlessFramework

                                                      protected serverlessFramework: () => boolean;

                                                        method start

                                                        start: () => Promise<void>;

                                                          method stop

                                                          stop: () => Promise<void>;

                                                            class HttpQueryError

                                                            class HttpQueryError extends Error {}

                                                              constructor

                                                              constructor(
                                                              statusCode: number,
                                                              message: string,
                                                              isGraphQLError?: boolean,
                                                              headers?: { [key: string]: string }
                                                              );

                                                                property headers

                                                                headers?: { [key: string]: string };

                                                                  property isGraphQLError

                                                                  isGraphQLError: boolean;

                                                                    property statusCode

                                                                    statusCode: number;

                                                                      Interfaces

                                                                      interface ApolloServerPluginCacheControlOptions

                                                                      interface ApolloServerPluginCacheControlOptions {}

                                                                        property calculateHttpHeaders

                                                                        calculateHttpHeaders?: boolean;

                                                                          property defaultMaxAge

                                                                          defaultMaxAge?: number;

                                                                            interface ApolloServerPluginDrainHttpServerOptions

                                                                            interface ApolloServerPluginDrainHttpServerOptions {}

                                                                              property httpServer

                                                                              httpServer: http.Server;

                                                                                property stopGracePeriodMillis

                                                                                stopGracePeriodMillis?: number;

                                                                                  interface ApolloServerPluginInlineTraceOptions

                                                                                  interface ApolloServerPluginInlineTraceOptions {}

                                                                                    property rewriteError

                                                                                    rewriteError?: ApolloServerPluginUsageReportingOptions<never>['rewriteError'];

                                                                                      interface ApolloServerPluginLandingPageDefaultBaseOptions

                                                                                      interface ApolloServerPluginLandingPageDefaultBaseOptions {}

                                                                                        property footer

                                                                                        footer?: boolean;

                                                                                          property version

                                                                                          version?: string;

                                                                                            interface ApolloServerPluginLandingPageLocalDefaultOptions

                                                                                            interface ApolloServerPluginLandingPageLocalDefaultOptions
                                                                                            extends ApolloServerPluginLandingPageDefaultBaseOptions {}

                                                                                              interface ApolloServerPluginLandingPageProductionDefaultOptions

                                                                                              interface ApolloServerPluginLandingPageProductionDefaultOptions
                                                                                              extends ApolloServerPluginLandingPageDefaultBaseOptions {}

                                                                                                property graphRef

                                                                                                graphRef?: string;

                                                                                                  interface ApolloServerPluginSchemaReportingOptions

                                                                                                  interface ApolloServerPluginSchemaReportingOptions {}

                                                                                                    property endpointUrl

                                                                                                    endpointUrl?: string;

                                                                                                      property fetcher

                                                                                                      fetcher?: typeof fetch;

                                                                                                        property initialDelayMaxMs

                                                                                                        initialDelayMaxMs?: number;

                                                                                                          property overrideReportedSchema

                                                                                                          overrideReportedSchema?: string;

                                                                                                            interface ApolloServerPluginUsageReportingOptions

                                                                                                            interface ApolloServerPluginUsageReportingOptions<TContext> {}

                                                                                                              property calculateSignature

                                                                                                              calculateSignature?: (ast: DocumentNode, operationName: string) => string;

                                                                                                                property debugPrintReports

                                                                                                                debugPrintReports?: boolean;

                                                                                                                  property endpointUrl

                                                                                                                  endpointUrl?: string;

                                                                                                                    property experimental_sendOperationAsTrace

                                                                                                                    experimental_sendOperationAsTrace?: (
                                                                                                                    trace: Trace,
                                                                                                                    statsReportKey: string
                                                                                                                    ) => boolean;

                                                                                                                      property fetcher

                                                                                                                      fetcher?: typeof fetch;

                                                                                                                        property generateClientInfo

                                                                                                                        generateClientInfo?: GenerateClientInfo<TContext>;

                                                                                                                          property includeRequest

                                                                                                                          includeRequest?: (
                                                                                                                          request:
                                                                                                                          | GraphQLRequestContextDidResolveOperation<TContext>
                                                                                                                          | GraphQLRequestContextWillSendResponse<TContext>
                                                                                                                          ) => Promise<boolean>;

                                                                                                                            property internal_includeTracesContributingToStats

                                                                                                                            internal_includeTracesContributingToStats?: boolean;

                                                                                                                              property logger

                                                                                                                              logger?: Logger;

                                                                                                                                property maxAttempts

                                                                                                                                maxAttempts?: number;

                                                                                                                                  property maxUncompressedReportSize

                                                                                                                                  maxUncompressedReportSize?: number;

                                                                                                                                    property minimumRetryDelayMs

                                                                                                                                    minimumRetryDelayMs?: number;

                                                                                                                                      property overrideReportedSchema

                                                                                                                                      overrideReportedSchema?: string;

                                                                                                                                        property reportErrorFunction

                                                                                                                                        reportErrorFunction?: (err: Error) => void;

                                                                                                                                          property reportIntervalMs

                                                                                                                                          reportIntervalMs?: number;

                                                                                                                                            property requestAgent

                                                                                                                                            requestAgent?: RequestAgent | false;

                                                                                                                                              property rewriteError

                                                                                                                                              rewriteError?: (err: GraphQLError) => GraphQLError | null;

                                                                                                                                                property sendHeaders

                                                                                                                                                sendHeaders?: SendValuesBaseOptions;

                                                                                                                                                  property sendReportsImmediately

                                                                                                                                                  sendReportsImmediately?: boolean;

                                                                                                                                                    property sendUnexecutableOperationDocuments

                                                                                                                                                    sendUnexecutableOperationDocuments?: boolean;

                                                                                                                                                      property sendVariableValues

                                                                                                                                                      sendVariableValues?: VariableValueOptions;

                                                                                                                                                        interface ClientInfo

                                                                                                                                                        interface ClientInfo {}

                                                                                                                                                          property clientName

                                                                                                                                                          clientName?: string;

                                                                                                                                                            property clientReferenceId

                                                                                                                                                            clientReferenceId?: string;

                                                                                                                                                              property clientVersion

                                                                                                                                                              clientVersion?: string;

                                                                                                                                                                interface Config

                                                                                                                                                                interface Config<ContextFunctionParams = any> extends BaseConfig {}

                                                                                                                                                                  property apollo

                                                                                                                                                                  apollo?: ApolloConfigInput;

                                                                                                                                                                    property context

                                                                                                                                                                    context?: Context | ContextFunction<ContextFunctionParams>;

                                                                                                                                                                      property experimental_approximateDocumentStoreMiB

                                                                                                                                                                      experimental_approximateDocumentStoreMiB?: number;

                                                                                                                                                                        property gateway

                                                                                                                                                                        gateway?: GatewayInterface;

                                                                                                                                                                          property introspection

                                                                                                                                                                          introspection?: boolean;

                                                                                                                                                                            property mockEntireSchema

                                                                                                                                                                            mockEntireSchema?: boolean;

                                                                                                                                                                              property mocks

                                                                                                                                                                              mocks?: boolean | IMocks;

                                                                                                                                                                                property modules

                                                                                                                                                                                modules?: GraphQLSchemaModule[];

                                                                                                                                                                                  property parseOptions

                                                                                                                                                                                  parseOptions?: ParseOptions;

                                                                                                                                                                                    property persistedQueries

                                                                                                                                                                                    persistedQueries?: PersistedQueryOptions | false;

                                                                                                                                                                                      property plugins

                                                                                                                                                                                      plugins?: PluginDefinition[];

                                                                                                                                                                                        property resolvers

                                                                                                                                                                                        resolvers?: IResolvers | Array<IResolvers>;

                                                                                                                                                                                          property schema

                                                                                                                                                                                          schema?: GraphQLSchema;

                                                                                                                                                                                            property stopOnTerminationSignals

                                                                                                                                                                                            stopOnTerminationSignals?: boolean;

                                                                                                                                                                                              property typeDefs

                                                                                                                                                                                              typeDefs?: DocumentNode | Array<DocumentNode> | string | Array<string>;

                                                                                                                                                                                                interface GatewayInterface

                                                                                                                                                                                                interface GatewayInterface {}

                                                                                                                                                                                                  method load

                                                                                                                                                                                                  load: (options: { apollo: ApolloConfig }) => Promise<GraphQLServiceConfig>;

                                                                                                                                                                                                    method onSchemaChange

                                                                                                                                                                                                    onSchemaChange: (callback: SchemaChangeCallback) => Unsubscriber;

                                                                                                                                                                                                      method onSchemaLoadOrUpdate

                                                                                                                                                                                                      onSchemaLoadOrUpdate: (
                                                                                                                                                                                                      callback: (schemaContext: {
                                                                                                                                                                                                      apiSchema: GraphQLSchema;
                                                                                                                                                                                                      coreSupergraphSdl: string;
                                                                                                                                                                                                      }) => void
                                                                                                                                                                                                      ) => Unsubscriber;

                                                                                                                                                                                                        method stop

                                                                                                                                                                                                        stop: () => Promise<void>;

                                                                                                                                                                                                          interface GraphQLOptions

                                                                                                                                                                                                          interface GraphQLServerOptions<TContext = Record<string, any>, TRootValue = any> {}

                                                                                                                                                                                                            property cache

                                                                                                                                                                                                            cache?: KeyValueCache;

                                                                                                                                                                                                              property context

                                                                                                                                                                                                              context?: TContext | (() => never);

                                                                                                                                                                                                                property dataSources

                                                                                                                                                                                                                dataSources?: () => DataSources<TContext>;

                                                                                                                                                                                                                  property debug

                                                                                                                                                                                                                  debug?: boolean;

                                                                                                                                                                                                                    property documentStore

                                                                                                                                                                                                                    documentStore?: InMemoryLRUCache<DocumentNode>;

                                                                                                                                                                                                                      property executor

                                                                                                                                                                                                                      executor?: GraphQLExecutor;

                                                                                                                                                                                                                        property fieldResolver

                                                                                                                                                                                                                        fieldResolver?: GraphQLFieldResolver<any, TContext>;

                                                                                                                                                                                                                          property formatError

                                                                                                                                                                                                                          formatError?: (error: GraphQLError) => GraphQLFormattedError;

                                                                                                                                                                                                                            property formatResponse

                                                                                                                                                                                                                            formatResponse?: (
                                                                                                                                                                                                                            response: GraphQLResponse,
                                                                                                                                                                                                                            requestContext: GraphQLRequestContext<TContext>
                                                                                                                                                                                                                            ) => GraphQLResponse | null;

                                                                                                                                                                                                                              property logger

                                                                                                                                                                                                                              logger?: Logger;

                                                                                                                                                                                                                                property parseOptions

                                                                                                                                                                                                                                parseOptions?: ParseOptions;

                                                                                                                                                                                                                                  property persistedQueries

                                                                                                                                                                                                                                  persistedQueries?: PersistedQueryOptions;

                                                                                                                                                                                                                                    property plugins

                                                                                                                                                                                                                                    plugins?: ApolloServerPlugin[];

                                                                                                                                                                                                                                      property rootValue

                                                                                                                                                                                                                                      rootValue?: ((parsedQuery: DocumentNode) => TRootValue) | TRootValue;

                                                                                                                                                                                                                                        property schema

                                                                                                                                                                                                                                        schema: GraphQLSchema;

                                                                                                                                                                                                                                          property schemaHash

                                                                                                                                                                                                                                          schemaHash: SchemaHash;

                                                                                                                                                                                                                                            property validationRules

                                                                                                                                                                                                                                            validationRules?: Array<(context: ValidationContext) => any>;

                                                                                                                                                                                                                                              interface GraphQLService

                                                                                                                                                                                                                                              interface GraphQLService extends GatewayInterface {}

                                                                                                                                                                                                                                                interface HttpQueryRequest

                                                                                                                                                                                                                                                interface HttpQueryRequest {}

                                                                                                                                                                                                                                                  property method

                                                                                                                                                                                                                                                  method: string;

                                                                                                                                                                                                                                                    property options

                                                                                                                                                                                                                                                    options:
                                                                                                                                                                                                                                                    | GraphQLOptions
                                                                                                                                                                                                                                                    | ((...args: Array<any>) => ValueOrPromise<GraphQLOptions>);

                                                                                                                                                                                                                                                      property query

                                                                                                                                                                                                                                                      query: Record<string, any> | Array<Record<string, any>>;

                                                                                                                                                                                                                                                        property request

                                                                                                                                                                                                                                                        request: Pick<Request, 'url' | 'method' | 'headers'>;

                                                                                                                                                                                                                                                          interface PersistedQueryOptions

                                                                                                                                                                                                                                                          interface PersistedQueryOptions {}

                                                                                                                                                                                                                                                            property cache

                                                                                                                                                                                                                                                            cache?: KeyValueCache;

                                                                                                                                                                                                                                                              property ttl

                                                                                                                                                                                                                                                              ttl?: number | null;

                                                                                                                                                                                                                                                                Type Aliases

                                                                                                                                                                                                                                                                type ApolloServerPluginLandingPageGraphQLPlaygroundOptions

                                                                                                                                                                                                                                                                type ApolloServerPluginLandingPageGraphQLPlaygroundOptions = Parameters<
                                                                                                                                                                                                                                                                typeof renderPlaygroundPage
                                                                                                                                                                                                                                                                >[0];

                                                                                                                                                                                                                                                                  type Context

                                                                                                                                                                                                                                                                  type Context<T = object> = T;

                                                                                                                                                                                                                                                                    type ContextFunction

                                                                                                                                                                                                                                                                    type ContextFunction<FunctionParams = any, ProducedContext = object> = (
                                                                                                                                                                                                                                                                    context: FunctionParams
                                                                                                                                                                                                                                                                    ) => ValueOrPromise<Context<ProducedContext>>;

                                                                                                                                                                                                                                                                      type GenerateClientInfo

                                                                                                                                                                                                                                                                      type GenerateClientInfo<TContext> = (
                                                                                                                                                                                                                                                                      requestContext: GraphQLRequestContext<TContext>
                                                                                                                                                                                                                                                                      ) => ClientInfo;

                                                                                                                                                                                                                                                                        type GraphQLServiceConfig

                                                                                                                                                                                                                                                                        type GraphQLServiceConfig = {
                                                                                                                                                                                                                                                                        schema: GraphQLSchema;
                                                                                                                                                                                                                                                                        executor: GraphQLExecutor | null;
                                                                                                                                                                                                                                                                        };

                                                                                                                                                                                                                                                                          type PluginDefinition

                                                                                                                                                                                                                                                                          type PluginDefinition = ApolloServerPlugin | (() => ApolloServerPlugin);

                                                                                                                                                                                                                                                                            type SchemaChangeCallback

                                                                                                                                                                                                                                                                            type SchemaChangeCallback = (apiSchema: GraphQLSchema) => void;

                                                                                                                                                                                                                                                                              type SendValuesBaseOptions

                                                                                                                                                                                                                                                                              type SendValuesBaseOptions =
                                                                                                                                                                                                                                                                              | {
                                                                                                                                                                                                                                                                              onlyNames: Array<String>;
                                                                                                                                                                                                                                                                              }
                                                                                                                                                                                                                                                                              | {
                                                                                                                                                                                                                                                                              exceptNames: Array<String>;
                                                                                                                                                                                                                                                                              }
                                                                                                                                                                                                                                                                              | {
                                                                                                                                                                                                                                                                              all: true;
                                                                                                                                                                                                                                                                              }
                                                                                                                                                                                                                                                                              | {
                                                                                                                                                                                                                                                                              none: true;
                                                                                                                                                                                                                                                                              };

                                                                                                                                                                                                                                                                                type Unsubscriber

                                                                                                                                                                                                                                                                                type Unsubscriber = () => void;

                                                                                                                                                                                                                                                                                  type VariableValueOptions

                                                                                                                                                                                                                                                                                  type VariableValueOptions =
                                                                                                                                                                                                                                                                                  | {
                                                                                                                                                                                                                                                                                  transform: (options: VariableValueTransformOptions) => Record<string, any>;
                                                                                                                                                                                                                                                                                  }
                                                                                                                                                                                                                                                                                  | SendValuesBaseOptions;

                                                                                                                                                                                                                                                                                    Package Files (14)

                                                                                                                                                                                                                                                                                    Dependencies (21)

                                                                                                                                                                                                                                                                                    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/apollo-server-core.

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