Skip to content
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

Add default Apollo Engine endpoint #1560

Merged
merged 1 commit into from May 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/loaders/apollo-engine/src/index.ts
Expand Up @@ -4,14 +4,16 @@ import { buildClientSchema } from 'graphql';

export interface ApolloEngineOptions extends SingleFileOptions {
engine: {
endpoint: string;
endpoint?: string;
apiKey: string;
};
graph: string;
variant: string;
headers?: Record<string, string>;
}

const DEFAULT_APOLLO_ENDPOINT = 'https://engine-graphql.apollographql.com/api/graphql';

export class ApolloEngineLoader implements SchemaLoader<ApolloEngineOptions> {
loaderId() {
return 'apollo-engine';
Expand All @@ -26,7 +28,7 @@ export class ApolloEngineLoader implements SchemaLoader<ApolloEngineOptions> {
}

async load(_: 'apollo-engine', options: ApolloEngineOptions): Promise<Source> {
const response = await fetch(options.engine.endpoint, {
const response = await fetch(options.engine.endpoint || DEFAULT_APOLLO_ENDPOINT, {
method: 'POST',
headers: {
'x-api-key': options.engine.apiKey,
Expand Down