Skip to content

Commit

Permalink
Throw if schema-reporting is enabled for either the gateway or for fe…
Browse files Browse the repository at this point in the history
…derated services
  • Loading branch information
sachindshinde committed Jun 15, 2020
1 parent 0c9ca40 commit a9c4b3d
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions packages/apollo-server-core/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,16 @@ export class ApolloServerBase {
// Don't add the extension here (we want to add it later in generateSchemaDerivedData).
}

if (gateway && typeof engine === 'object' && engine.experimental_schemaReporting) {
throw new Error(
[
"Schema reporting is not yet compatible with the gateway. If you're",
"interested in using schema reporting with the gateway, please",
"contact Apollo support.",
].join(' '),
);
}

if (gateway && subscriptions !== false) {
// TODO: this could be handled by adjusting the typings to keep gateway configs and non-gateway configs separate.
throw new Error(
Expand Down Expand Up @@ -691,9 +701,13 @@ export class ApolloServerBase {
// survive transformations like monkey-patching a boolean field onto the
// schema.
//
// The only thing this is used for is determining whether traces should be
// added to responses if requested with an HTTP header; if there's a false
// positive, that feature can be disabled by specifying `engine: false`.
// This is used for two things:
// 1) determining whether traces should be added to responses if requested
// with an HTTP header; if there's a false positive, that feature can be
// disabled by specifying `engine: false`.
// 2) determining whether schema-reporting should be allowed; federated
// services shouldn't be reporting schemas, and we accordingly throw if
// it's attempted.
private schemaIsFederated(schema: GraphQLSchema): boolean {
const serviceType = schema.getType('_Service');
if (!(serviceType && isObjectType(serviceType))) {
Expand Down Expand Up @@ -766,6 +780,16 @@ export class ApolloServerBase {
'to report metrics to Apollo Graph Manager. You should only configure your Apollo gateway ' +
'to report metrics to Apollo Graph Manager.',
);

if (typeof engine === 'object' && engine.experimental_schemaReporting) {
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.",
].join(' '),
);
}
}
pluginsToInit.push(this.engineReportingAgent!.newPlugin());
} else if (engine !== false && federatedSchema) {
Expand Down

0 comments on commit a9c4b3d

Please sign in to comment.