Skip to content

Commit

Permalink
Fix misuse of schemaIsFederated()
Browse files Browse the repository at this point in the history
  • Loading branch information
sachindshinde committed Jun 22, 2021
1 parent 8958f86 commit 0d2d379
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions packages/apollo-server-core/src/plugin/schemaReporting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,17 @@ export function ApolloServerPluginSchemaReporting(
}
}

const isFederatedSchemaReporting = schemaIsFederated(schema);
if (overrideReportedSchema !== undefined) {
if (isFederatedSchemaReporting) {
throw new Error(
[
`The overrideReportedSchema option is incompatible with gateways`,
`as the schema SDL is given directly by gateway. If you would`,
`like to customize the schema SDL reported, please instead set`,
`the option experimental_updateSupergraphSdl in your gateway`,
`configuration.`,
].join(' '),
);
}
logger.info(
'Apollo schema reporting: schema to report has been overridden',
if (schemaIsFederated(schema)) {
throw Error(
[
'Schema reporting is not yet compatible with federated services.',
"If you're interested in using schema reporting with federated",
'services, please contact Apollo support. To set up managed federation, see',
'https://go.apollo.dev/s/managed-federation',
].join(' '),
);
}

if (endpointUrl !== undefined) {
logger.info(
`Apollo schema reporting: schema reporting URL override: ${endpointUrl}`,
Expand Down Expand Up @@ -153,6 +147,23 @@ export function ApolloServerPluginSchemaReporting(
schemaDidLoadOrUpdate({ apiSchema, coreSupergraphSdl }): void {
currentSchemaReporter?.stop();

if (overrideReportedSchema !== undefined) {
if (coreSupergraphSdl !== undefined) {
throw new Error(
[
`The overrideReportedSchema option is incompatible with gateways`,
`as the schema SDL is given directly by gateway. If you would`,
`like to customize the schema SDL reported, please instead set`,
`the option experimental_updateSupergraphSdl in your gateway`,
`configuration.`,
].join(' '),
);
}
logger.info(
'Apollo schema reporting: schema to report has been overridden',
);
}

const coreSchema =
coreSupergraphSdl ??
overrideReportedSchema ??
Expand Down

0 comments on commit 0d2d379

Please sign in to comment.