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 68df2a6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
9 changes: 9 additions & 0 deletions packages/apollo-server-core/src/ApolloServer.ts
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
30 changes: 16 additions & 14 deletions 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';
Expand Down Expand Up @@ -42,23 +42,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 68df2a6

Please sign in to comment.