diff --git a/packages/apollo-server-core/src/ApolloServer.ts b/packages/apollo-server-core/src/ApolloServer.ts index 6c58cbd49c3..891c0d3020e 100644 --- a/packages/apollo-server-core/src/ApolloServer.ts +++ b/packages/apollo-server-core/src/ApolloServer.ts @@ -134,6 +134,7 @@ export class ApolloServerBase { schemaDirectives, modules, typeDefs, + parseOptions, introspection, mocks, mockEntireSchema, @@ -292,6 +293,14 @@ export class ApolloServerBase { typeDefs: augmentedTypeDefs, schemaDirectives, resolvers, + parseOptions: { + // Since ApolloServer does not use the location/token information the + // graphql/language/parser attaches to the schema, we can save some + // memory (and potentially some parsing time) with this default. + noLocation: true, + // Other options can be passed into the ApolloServerBase constructor. + ...parseOptions, + }, }); } diff --git a/packages/apollo-server-core/src/types.ts b/packages/apollo-server-core/src/types.ts index 36d050ad487..77f99b9b5bb 100644 --- a/packages/apollo-server-core/src/types.ts +++ b/packages/apollo-server-core/src/types.ts @@ -1,5 +1,5 @@ import { GraphQLSchema, DocumentNode } from 'graphql'; -import { SchemaDirectiveVisitor, IResolvers, IMocks } from 'graphql-tools'; +import { SchemaDirectiveVisitor, IResolvers, IMocks, GraphQLParseOptions } from 'graphql-tools'; import { ConnectionContext } from 'subscriptions-transport-ws'; import WebSocket from 'ws'; import { GraphQLExtension } from 'graphql-extensions'; @@ -42,23 +42,25 @@ export interface SubscriptionServerOptions { onDisconnect?: (websocket: WebSocket, context: ConnectionContext) => any; } +type BaseConfig = Pick< + GraphQLOptions>, + | 'formatError' + | 'debug' + | 'rootValue' + | 'validationRules' + | 'formatResponse' + | 'fieldResolver' + | 'tracing' + | 'dataSources' + | 'cache' +>; + // This configuration is shared between all integrations and should include // fields that are not specific to a single integration -export interface Config - extends Pick< - GraphQLOptions>, - | 'formatError' - | 'debug' - | 'rootValue' - | 'validationRules' - | 'formatResponse' - | 'fieldResolver' - | 'tracing' - | 'dataSources' - | 'cache' - > { +export interface Config extends BaseConfig { modules?: GraphQLSchemaModule[]; typeDefs?: DocumentNode | Array; + parseOptions?: GraphQLParseOptions; resolvers?: IResolvers; schema?: GraphQLSchema; schemaDirectives?: Record;