File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
packages/loaders/apollo-engine/src Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 1
- import { SchemaLoader , Source } from '@graphql-tools/utils' ;
1
+ import { SchemaLoader , Source , SingleFileOptions } from '@graphql-tools/utils' ;
2
2
import { fetch } from 'cross-fetch' ;
3
3
import { buildClientSchema } from 'graphql' ;
4
4
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 > {
6
16
loaderId ( ) {
7
17
return 'apollo-engine' ;
8
18
}
@@ -15,14 +25,17 @@ export class ApolloEngineLoader implements SchemaLoader {
15
25
return false ;
16
26
}
17
27
18
- async load ( _ : 'apollo-engine' , options : any ) : Promise < Source > {
28
+ async load ( _ : 'apollo-engine' , options : ApolloEngineOptions ) : Promise < Source > {
19
29
const response = await fetch ( options . engine . endpoint , {
20
30
method : 'POST' ,
21
31
headers : {
22
32
'x-api-key' : options . engine . apiKey ,
23
33
'apollo-client-name' : 'Apollo Language Server' ,
24
34
'apollo-client-reference-id' : '146d29c0-912c-46d3-b686-920e52586be6' ,
25
35
'apollo-client-version' : '2.6.8' ,
36
+ 'Content-Type' : 'application/json' ,
37
+ Accept : 'application/json' ,
38
+ ...options . headers ,
26
39
} ,
27
40
body : JSON . stringify ( {
28
41
query : SCHEMA_QUERY ,
You can’t perform that action at this time.
0 commit comments