Skip to content

Commit 8f01ed0

Browse files
committed
1 parent 28d41d0 commit 8f01ed0

File tree

1 file changed

+16
-3
lines changed
  • packages/loaders/apollo-engine/src

1 file changed

+16
-3
lines changed

packages/loaders/apollo-engine/src/index.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
import { SchemaLoader, Source } from '@graphql-tools/utils';
1+
import { SchemaLoader, Source, SingleFileOptions } from '@graphql-tools/utils';
22
import { fetch } from 'cross-fetch';
33
import { buildClientSchema } from 'graphql';
44

5-
export class ApolloEngineLoader implements SchemaLoader {
5+
export interface ApolloEngineOptions extends SingleFileOptions {
6+
engine: {
7+
endpoint: string;
8+
apiKey: string;
9+
};
10+
graph: string;
11+
variant: string;
12+
headers?: Record<string, string>;
13+
}
14+
15+
export class ApolloEngineLoader implements SchemaLoader<ApolloEngineOptions> {
616
loaderId() {
717
return 'apollo-engine';
818
}
@@ -15,14 +25,17 @@ export class ApolloEngineLoader implements SchemaLoader {
1525
return false;
1626
}
1727

18-
async load(_: 'apollo-engine', options: any): Promise<Source> {
28+
async load(_: 'apollo-engine', options: ApolloEngineOptions): Promise<Source> {
1929
const response = await fetch(options.engine.endpoint, {
2030
method: 'POST',
2131
headers: {
2232
'x-api-key': options.engine.apiKey,
2333
'apollo-client-name': 'Apollo Language Server',
2434
'apollo-client-reference-id': '146d29c0-912c-46d3-b686-920e52586be6',
2535
'apollo-client-version': '2.6.8',
36+
'Content-Type': 'application/json',
37+
Accept: 'application/json',
38+
...options.headers,
2639
},
2740
body: JSON.stringify({
2841
query: SCHEMA_QUERY,

0 commit comments

Comments
 (0)