File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @graphql-tools/utils ' : patch
3
+ ---
4
+
5
+ fix(utils): bring back breaking change for fixSchemaAst
Original file line number Diff line number Diff line change
1
+ import { GraphQLSchema , BuildSchemaOptions , buildASTSchema } from 'graphql' ;
2
+ import { SchemaPrintOptions } from './types' ;
3
+ import { getDocumentNodeFromSchema } from './print-schema-with-directives' ;
4
+
5
+ function buildFixedSchema ( schema : GraphQLSchema , options : BuildSchemaOptions & SchemaPrintOptions ) {
6
+ const document = getDocumentNodeFromSchema ( schema ) ;
7
+ return buildASTSchema ( document , {
8
+ ...( options || { } ) ,
9
+ } ) ;
10
+ }
11
+
12
+ export function fixSchemaAst ( schema : GraphQLSchema , options : BuildSchemaOptions & SchemaPrintOptions ) {
13
+ // eslint-disable-next-line no-undef-init
14
+ let schemaWithValidAst : GraphQLSchema | undefined = undefined ;
15
+ if ( ! schema . astNode || ! schema . extensionASTNodes ) {
16
+ schemaWithValidAst = buildFixedSchema ( schema , options ) ;
17
+ }
18
+
19
+ if ( ! schema . astNode && schemaWithValidAst ?. astNode ) {
20
+ schema . astNode = schemaWithValidAst . astNode ;
21
+ }
22
+ if ( ! schema . extensionASTNodes && schemaWithValidAst ?. astNode ) {
23
+ schema . extensionASTNodes = schemaWithValidAst . extensionASTNodes ;
24
+ }
25
+ return schema ;
26
+ }
Original file line number Diff line number Diff line change @@ -46,3 +46,4 @@ export * from './comments';
46
46
export * from './collectFields' ;
47
47
export * from './inspect' ;
48
48
export * from './memoize' ;
49
+ export * from './fixSchemaAst' ;
You can’t perform that action at this time.
0 commit comments