Skip to content

Commit

Permalink
Gateway - don't log updates on startup (#3421)
Browse files Browse the repository at this point in the history
Only log "updating schema" if a previous schema exists

In the case of a new schema (on first load), log the service id,
variant, and mode on which the gateway is running.
  • Loading branch information
trevor-scheer committed Oct 18, 2019
1 parent cdec277 commit e57036a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/apollo-gateway/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
1. Previously, the `experimental_didUpdateComposition` hook wouldn't be reliably called unless the `experimental_pollInterval` was set. If it _was_ called, it was sporadic and didn't necessarily mark the timing of an actual composition update. After this change, the hook is called on a successful composition update.
2. The `experimental_pollInterval` configuration option now affects both the GCS polling interval when gateway is configured for managed federation, as well as the polling interval of services. The former being newly introduced behavior.
* Gateway cached DataSource bug [#3412](https://github.com/apollographql/apollo-server/pull/3412) introduces a fix for managed federation users where `DataSource`s wouldn't update correctly if a service's url changed. This bug was introduced with heavier DataSource caching in [#3388](https://github.com/apollographql/apollo-server/pull/3388). By inspecting the `url` as well, `DataSource`s will now update correctly when a composition update occurs.

* Gateway - don't log updates on startup [#3421](https://github.com/apollographql/apollo-server/pull/3421) Fine tune gateway startup logging - on load, instead of logging an "update", log the service id, variant, and mode in which gateway is running.
# v.0.10.7

> [See complete versioning details.](https://github.com/apollographql/apollo-server/commit/fc7462ec5f8604bd6cba99aa9a377a9b8e045566)
Expand Down
13 changes: 10 additions & 3 deletions packages/apollo-gateway/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ export class ApolloGateway implements GraphQLService {

public async load(options?: { engine?: GraphQLServiceEngineConfig }) {
await this.updateComposition(options);
const { graphId, graphVariant } = (options && options.engine) || {};
const mode = isManagedConfig(this.config) ? 'managed' : 'unmanaged';

this.logger.info(
`Gateway successfully loaded schema.\n\t* Mode: ${mode}${graphId ? `\n\t* Service: ${graphId}@${graphVariant || 'current'}`: ''}`,
);
if (this.experimental_pollInterval) {
setInterval(
() => this.updateComposition(options),
Expand Down Expand Up @@ -292,15 +298,16 @@ export class ApolloGateway implements GraphQLService {
) {
this.logger.debug('No change in service definitions since last check');
return;
} else {
this.serviceDefinitions = result.serviceDefinitions;
}

if (previousSchema) {
this.logger.info('Gateway config has changed, updating schema');
}

this.compositionMetadata = result.compositionMetadata;
this.serviceDefinitions = result.serviceDefinitions;

if (this.queryPlanStore) this.queryPlanStore.flush();
this.logger.info('Gateway config has changed, updating schema');

this.schema = this.createSchema(result.serviceDefinitions);
try {
Expand Down

0 comments on commit e57036a

Please sign in to comment.