diff --git a/packages/apollo-engine-reporting/src/agent.ts b/packages/apollo-engine-reporting/src/agent.ts index b6b91f830d1..2b99153ce8d 100644 --- a/packages/apollo-engine-reporting/src/agent.ts +++ b/packages/apollo-engine-reporting/src/agent.ts @@ -389,6 +389,7 @@ export class EngineReportingAgent { }; private readonly tracesEndpointUrl: string; + private readonly schemaReport: boolean; public constructor(options: EngineReportingOptions = {}) { this.options = options; @@ -407,6 +408,13 @@ export class EngineReportingAgent { ); } + + if (options.experimental_schemaReporting !== undefined) { + this.schemaReport = options.experimental_schemaReporting; + } else { + this.schemaReport = process.env.APOLLO_SCHEMA_REPORTING === "true" + } + // Since calculating the signature for Engine reporting is potentially an // expensive operation, we'll cache the signatures we generate and re-use // them based on repeated traces for the same `queryHash`. @@ -469,6 +477,7 @@ export class EngineReportingAgent { return plugin(this.options, this.addTrace.bind(this), { startSchemaReporting: this.startSchemaReporting.bind(this), executableSchemaIdGenerator: this.executableSchemaIdGenerator.bind(this), + schemaReport: this.schemaReport, }); } diff --git a/packages/apollo-engine-reporting/src/plugin.ts b/packages/apollo-engine-reporting/src/plugin.ts index b960df381df..80c7a63c3b8 100644 --- a/packages/apollo-engine-reporting/src/plugin.ts +++ b/packages/apollo-engine-reporting/src/plugin.ts @@ -34,6 +34,7 @@ export const plugin = ( { startSchemaReporting, executableSchemaIdGenerator, + schemaReport, }: { startSchemaReporting: ({ executableSchema, @@ -43,6 +44,7 @@ export const plugin = ( executableSchemaId: string; }) => void; executableSchemaIdGenerator: (schema: string | GraphQLSchema) => string; + schemaReport?: boolean; }, ): ApolloServerPlugin => { /** @@ -57,7 +59,7 @@ export const plugin = ( return { serverWillStart: function({ schema }) { - if (!options.experimental_schemaReporting) return; + if (!schemaReport) return; startSchemaReporting({ executableSchema: options.experimental_overrideReportedSchema || printSchema(schema),