Skip to content

Follow-up to #819: don't import engine config type #822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion gateway-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
GraphQLService,
SchemaChangeCallback,
Unsubscriber,
GraphQLServiceEngineConfig,
} from 'apollo-server-core';
import {
GraphQLExecutionResult,
Expand Down Expand Up @@ -136,12 +135,18 @@ type GatewayState =
}
| { phase: 'polling'; pollingDonePromise: Promise<void> };

// We want to be compatible with `load()` as called by both AS2 and AS3, so we
// define its argument types ourselves instead of relying on imports.

// This is what AS3's ApolloConfig looks like; it's what we'll save internally.
interface ApolloConfigFromAS3 {
key?: string;
keyHash?: string;
graphRef?: string;
}

// This interface matches what we may receive from either version. We convert it
// to ApolloConfigFromAS3.
interface ApolloConfigFromAS2Or3 {
key?: string;
keyHash?: string;
Expand All @@ -150,6 +155,15 @@ interface ApolloConfigFromAS2Or3 {
graphVariant?: string;
}

// This interface was the only way this data was provided prior to AS 2.18; it
// is being removed in AS 3, so we define our own version.
interface GraphQLServiceEngineConfig {
apiKeyHash: string;
graphId: string;
graphVariant?: string;
};


export class ApolloGateway implements GraphQLService {
public schema?: GraphQLSchema;
private serviceMap: DataSourceMap = Object.create(null);
Expand Down