Skip to content

Commit

Permalink
Pass noLocation:true to schema parser by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Feb 8, 2019
1 parent 5065360 commit 8cf0ac2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
9 changes: 9 additions & 0 deletions packages/apollo-server-core/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export class ApolloServerBase {
schemaDirectives,
modules,
typeDefs,
parseOptions,
introspection,
mocks,
mockEntireSchema,
Expand Down Expand Up @@ -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,
},
});
}

Expand Down
35 changes: 21 additions & 14 deletions packages/apollo-server-core/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
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';
Expand Down Expand Up @@ -42,23 +47,25 @@ export interface SubscriptionServerOptions {
onDisconnect?: (websocket: WebSocket, context: ConnectionContext) => any;
}

type BaseConfig = Pick<
GraphQLOptions<Context<any>>,
| '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<Context<any>>,
| 'formatError'
| 'debug'
| 'rootValue'
| 'validationRules'
| 'formatResponse'
| 'fieldResolver'
| 'tracing'
| 'dataSources'
| 'cache'
> {
export interface Config extends BaseConfig {
modules?: GraphQLSchemaModule[];
typeDefs?: DocumentNode | Array<DocumentNode>;
parseOptions?: GraphQLParseOptions;
resolvers?: IResolvers;
schema?: GraphQLSchema;
schemaDirectives?: Record<string, typeof SchemaDirectiveVisitor>;
Expand Down

0 comments on commit 8cf0ac2

Please sign in to comment.