@@ -3,11 +3,12 @@ import {
3
3
findBreakingChanges ,
4
4
findDangerousChanges ,
5
5
GraphQLSchema ,
6
- introspectionQuery ,
7
6
buildClientSchema ,
8
7
buildSchema ,
9
8
DangerousChange ,
10
- BreakingChange
9
+ BreakingChange ,
10
+ introspectionFromSchema ,
11
+ getIntrospectionQuery
11
12
} from 'graphql' ;
12
13
import fs from 'fs' ;
13
14
import isGlob from 'is-glob' ;
@@ -23,6 +24,7 @@ async function fetchRemoteSchema(
23
24
endpoint : string ,
24
25
headers ?: Headers
25
26
) : Promise < GraphQLSchema > {
27
+ const introspectionQuery = getIntrospectionQuery ( { descriptions : false } ) ;
26
28
const res = await fetch ( endpoint , {
27
29
method : 'POST' ,
28
30
headers : {
@@ -46,19 +48,23 @@ async function fetchRemoteSchema(
46
48
}
47
49
48
50
function readLocalSchema ( schemaPath : string ) : GraphQLSchema {
51
+ let schemaString : string ;
52
+
49
53
if ( isGlob ( schemaPath ) ) {
50
54
const typesArray = fileLoader ( schemaPath ) ;
51
55
52
56
if ( typesArray . length === 0 ) {
53
57
throw new Error ( `No types found with glob pattern '${ schemaPath } '` ) ;
54
58
}
55
59
56
- const mergedSchema = mergeTypes ( typesArray , { all : true } ) ;
57
- return buildSchema ( mergedSchema ) ;
60
+ schemaString = mergeTypes ( typesArray , { all : true } ) ;
58
61
} else {
59
- const schemaString = fs . readFileSync ( schemaPath , 'utf8' ) ;
60
- return buildSchema ( schemaString ) ;
62
+ schemaString = fs . readFileSync ( schemaPath , 'utf8' ) ;
61
63
}
64
+
65
+ const schema = buildSchema ( schemaString ) ;
66
+ const introspection = introspectionFromSchema ( schema , { descriptions : false } )
67
+ return buildClientSchema ( introspection ) ;
62
68
}
63
69
64
70
async function getSchema (
0 commit comments