From bc18800556b2ebe7e864fcae7bba5393a00375df Mon Sep 17 00:00:00 2001 From: David Glasser Date: Fri, 7 May 2021 11:20:32 -0700 Subject: [PATCH] Remove some remaining references to "engine" (#5192) This branch previously had most references to `engine` options and `ENGINE_SCHEMA_TAG` removed but the merge from v2.18 restored some of them. Fixes #5191. --- docs/source/api/apollo-server.md | 17 ------------- docs/source/api/plugin/inline-trace.md | 2 -- docs/source/api/plugin/schema-reporting.md | 2 -- docs/source/api/plugin/usage-reporting.md | 2 -- .../src/determineApolloConfig.ts | 20 ++------------- .../apollo-server-core/src/requestPipeline.ts | 2 +- packages/apollo-server-core/src/types.ts | 10 -------- .../src/utils/pluginTestHarness.ts | 2 +- .../src/ApolloServer.ts | 25 +++++++++---------- 9 files changed, 16 insertions(+), 66 deletions(-) diff --git a/docs/source/api/apollo-server.md b/docs/source/api/apollo-server.md index 1afa534d733..95b7f0dfbd2 100644 --- a/docs/source/api/apollo-server.md +++ b/docs/source/api/apollo-server.md @@ -308,23 +308,6 @@ An object containing configuration options for connecting Apollo Server to [Apol - - - -###### `engine` - -`Object` or `Boolean` - - - -**Deprecated as of Apollo Server v2.18.** New projects should instead use Apollo Server's Studio connection plugins. For details, see [the migration docs](../migration-engine-plugins/). - -An object containing configuration options for connecting Apollo Server to [Apollo Studio](https://www.apollographql.com/docs/studio/). - - - - - diff --git a/docs/source/api/plugin/inline-trace.md b/docs/source/api/plugin/inline-trace.md index 820f3267016..8524f0ece97 100644 --- a/docs/source/api/plugin/inline-trace.md +++ b/docs/source/api/plugin/inline-trace.md @@ -46,8 +46,6 @@ Note that when this plugin is installed in your app, any client can request a tr (Note: in addition to this plugin (which adds a base64-encoded trace to the `ftv1` extension of responses), Apollo Server also contains support for an older JSON-based format which is enabled if you pass `tracing: true` to the `ApolloServer` constructor. This format was designed for use with a no longer supported tool called `engineproxy`, and also is recognized by graphql-playground. This format was more verbose due to its use of JSON and the way that it represented trace node IDs. Enabling it is not recommended.) -This plugin was introduced in Apollo Server 2.18. In previous versions, inline tracing was configured using the `engine` option to the `ApolloServer` constructor. That option continues to work; see [the migration guide](../../migration-engine-plugins/) for details. - ## Options diff --git a/docs/source/api/plugin/schema-reporting.md b/docs/source/api/plugin/schema-reporting.md index d1777048312..2a268ab0490 100644 --- a/docs/source/api/plugin/schema-reporting.md +++ b/docs/source/api/plugin/schema-reporting.md @@ -29,8 +29,6 @@ const server = new ApolloServer({ }); ``` -This plugin was introduced in Apollo Server 2.18. In previous versions, schema reporting was configured using the `engine` option to the `ApolloServer` constructor. That option continues to work; see [the migration guide](../../migration-engine-plugins/) for details. - ## Options
diff --git a/docs/source/api/plugin/usage-reporting.md b/docs/source/api/plugin/usage-reporting.md index 1bcac354154..765e6a5a64f 100644 --- a/docs/source/api/plugin/usage-reporting.md +++ b/docs/source/api/plugin/usage-reporting.md @@ -6,8 +6,6 @@ api_reference: true Apollo Server has a built-in usage reporting plugin that gathers data on how your clients use the operations and fields in your GraphQL schema. The plugin also handles pushing this usage data to [Apollo Studio](https://www.apollographql.com/docs/studio/), as described in [Metrics and logging](../../monitoring/metrics/). -> This plugin was introduced in Apollo Server 2.18. In previous versions, usage reporting is configured by providing the `engine` option to the `ApolloServer` constructor. That option continues to work (but is now deprecated). See [the migration guide](../../migration-engine-plugins/) for details. - ## Default installation Apollo Server automatically installs and enables this plugin with default settings if you [provide a graph API key to Apollo Server](https://www.apollographql.com/docs/apollo-server/monitoring/metrics/#connecting-to-apollo-studio) (usually by setting the value of the `APOLLO_KEY` environment variable). No other action is required. diff --git a/packages/apollo-server-core/src/determineApolloConfig.ts b/packages/apollo-server-core/src/determineApolloConfig.ts index cb483f230d4..12fa9775207 100644 --- a/packages/apollo-server-core/src/determineApolloConfig.ts +++ b/packages/apollo-server-core/src/determineApolloConfig.ts @@ -1,13 +1,8 @@ import { ApolloConfig, ApolloConfigInput, Logger } from 'apollo-server-types'; import createSHA from './utils/createSHA'; -// This function combines the newer `apollo` constructor argument, the older -// `engine` constructor argument, and some environment variables to come up -// with a full ApolloConfig. -// -// The caller ensures that only one of the two constructor arguments is actually -// provided and warns if `engine` was provided, but it is this function's job -// to warn if old environment variables are used. +// This function combines the `apollo` constructor argument and some environment +// variables to come up with a full ApolloConfig. export function determineApolloConfig( input: ApolloConfigInput | undefined, logger: Logger, @@ -18,7 +13,6 @@ export function determineApolloConfig( APOLLO_KEY, APOLLO_GRAPH_ID, APOLLO_GRAPH_VARIANT, - ENGINE_SCHEMA_TAG, } = process.env; // Determine key. @@ -53,17 +47,7 @@ export function determineApolloConfig( if (input?.graphVariant) { apolloConfig.graphVariant = input.graphVariant; } else if (APOLLO_GRAPH_VARIANT) { - if (ENGINE_SCHEMA_TAG) { - throw new Error( - '`APOLLO_GRAPH_VARIANT` and `ENGINE_SCHEMA_TAG` (deprecated) environment variables must not both be set.', - ); - } apolloConfig.graphVariant = APOLLO_GRAPH_VARIANT; - } else if (ENGINE_SCHEMA_TAG) { - logger.warn( - '[deprecated] The `ENGINE_SCHEMA_TAG` environment variable has been renamed to `APOLLO_GRAPH_VARIANT`.', - ); - apolloConfig.graphVariant = ENGINE_SCHEMA_TAG; } else if (apolloConfig.key) { // Leave the value 'current' in apolloConfig.graphVariant. // We warn if it looks like they're trying to use Apollo registry features, but there's diff --git a/packages/apollo-server-core/src/requestPipeline.ts b/packages/apollo-server-core/src/requestPipeline.ts index efbcd063103..9db2c637d14 100644 --- a/packages/apollo-server-core/src/requestPipeline.ts +++ b/packages/apollo-server-core/src/requestPipeline.ts @@ -510,7 +510,7 @@ export async function processGraphQLRequest( if (config.executor) { // XXX Nothing guarantees that the only errors thrown or returned // in result.errors are GraphQLErrors, even though other code - // (eg apollo-engine-reporting) assumes that. + // (eg usage reporting) assumes that. return await config.executor(requestContext); } else { return await graphqlExecute(executionArgs); diff --git a/packages/apollo-server-core/src/types.ts b/packages/apollo-server-core/src/types.ts index 8a9754880f6..a2b4ba9f534 100644 --- a/packages/apollo-server-core/src/types.ts +++ b/packages/apollo-server-core/src/types.ts @@ -59,19 +59,9 @@ export type GraphQLServiceConfig = { executor: GraphQLExecutor; }; -/** - * This is an older format for the data that now lives in ApolloConfig. - */ -export type GraphQLServiceEngineConfig = { - apiKeyHash: string; - graphId: string; - graphVariant?: string; -}; - export interface GraphQLService { load(options: { apollo?: ApolloConfig; - engine?: GraphQLServiceEngineConfig; // deprecated; use `apollo` instead }): Promise; onSchemaChange(callback: SchemaChangeCallback): Unsubscriber; // Note: The `TContext` typing here is not conclusively behaving as we expect: diff --git a/packages/apollo-server-core/src/utils/pluginTestHarness.ts b/packages/apollo-server-core/src/utils/pluginTestHarness.ts index 8ad056f731e..2b4b40f5301 100644 --- a/packages/apollo-server-core/src/utils/pluginTestHarness.ts +++ b/packages/apollo-server-core/src/utils/pluginTestHarness.ts @@ -212,7 +212,7 @@ export default async function pluginTestHarness({ requestContext.operation = operation || undefined; // We'll set `operationName` to `null` for anonymous operations. Note that - // apollo-engine-reporting relies on the fact that the requestContext passed + // usage reporting relies on the fact that the requestContext passed // to requestDidStart is mutated to add this field before requestDidEnd is // called requestContext.operationName = diff --git a/packages/apollo-server-integration-testsuite/src/ApolloServer.ts b/packages/apollo-server-integration-testsuite/src/ApolloServer.ts index 8795eeecfdb..cdb5e365ef6 100644 --- a/packages/apollo-server-integration-testsuite/src/ApolloServer.ts +++ b/packages/apollo-server-integration-testsuite/src/ApolloServer.ts @@ -1793,7 +1793,7 @@ export function testApolloServer( }); describe('usage reporting', () => { - async function makeFakeTestableEngineServer({ + async function makeFakeUsageReportingServer({ status, waitWriteResponse = false, }: { @@ -1801,28 +1801,28 @@ export function testApolloServer( waitWriteResponse?: boolean; }) { const writeResponsePromise = resolvable(); - const fakeEngineServer = http.createServer(async (_, res) => { + const fakeUsageReportingServer = http.createServer(async (_, res) => { await writeResponsePromise; res.writeHead(status); res.end('Important text in the body'); }); await new Promise((resolve) => { - fakeEngineServer.listen(0, '127.0.0.1', () => { + fakeUsageReportingServer.listen(0, '127.0.0.1', () => { resolve(); }); }); async function closeServer() { await new Promise((resolve) => - fakeEngineServer.close(() => resolve()), + fakeUsageReportingServer.close(() => resolve()), ); } - const { family, address, port } = (fakeEngineServer.address() as AddressInfo); + const { family, address, port } = (fakeUsageReportingServer.address() as AddressInfo); if (family !== 'IPv4') { throw new Error(`The family was unexpectedly ${family}.`); } - const fakeEngineUrl = `http://${address}:${port}`; + const fakeUsageReportingUrl = `http://${address}:${port}`; if (!waitWriteResponse) { writeResponsePromise.resolve(); @@ -1830,8 +1830,7 @@ export function testApolloServer( return { closeServer, - fakeEngineServer, - fakeEngineUrl, + fakeUsageReportingUrl, writeResponseResolve: () => writeResponsePromise.resolve(), }; } @@ -1845,9 +1844,9 @@ export function testApolloServer( const { closeServer, - fakeEngineUrl, + fakeUsageReportingUrl, writeResponseResolve, - } = await makeFakeTestableEngineServer({ + } = await makeFakeUsageReportingServer({ status, waitWriteResponse: true, }); @@ -1884,7 +1883,7 @@ export function testApolloServer( }, plugins: [ ApolloServerPluginUsageReporting({ - endpointUrl: fakeEngineUrl, + endpointUrl: fakeUsageReportingUrl, reportIntervalMs: 1, maxAttempts: 3, requestAgent, @@ -2140,7 +2139,7 @@ export function testApolloServer( plugins: [ ApolloServerPluginInlineTrace({ rewriteError(err) { - err.message = `Rewritten for Engine: ${err.message}`; + err.message = `Rewritten for Usage Reporting: ${err.message}`; return err; }, }), @@ -2164,7 +2163,7 @@ export function testApolloServer( const encoded = Buffer.from(ftv1, 'base64'); const trace = Trace.decode(encoded); expect(trace.root!.child![0].error![0].message).toBe( - 'Rewritten for Engine: It broke', + 'Rewritten for Usage Reporting: It broke', ); }); });