@@ -32,9 +32,10 @@ export function buildInfoForAllScalars(
32
32
const fieldNodes : FieldNode [ ] = [ ]
33
33
const type = getTypeForRootFieldName ( rootFieldName , operation , schema )
34
34
35
+ let selections : FieldNode [ ] | undefined
35
36
if ( type instanceof GraphQLObjectType ) {
36
37
const fields = type . getFields ( )
37
- const selections = Object . keys ( fields )
38
+ selections = Object . keys ( fields )
38
39
. filter ( f => isScalar ( fields [ f ] . type ) )
39
40
. map < FieldNode > ( fieldName => {
40
41
const field = fields [ fieldName ]
@@ -43,15 +44,16 @@ export function buildInfoForAllScalars(
43
44
name : { kind : 'Name' , value : field . name } ,
44
45
}
45
46
} )
46
- const fieldNode : FieldNode = {
47
- kind : 'Field' ,
48
- name : { kind : 'Name' , value : rootFieldName } ,
49
- selectionSet : { kind : 'SelectionSet' , selections } ,
50
- }
47
+ }
51
48
52
- fieldNodes . push ( fieldNode )
49
+ const fieldNode : FieldNode = {
50
+ kind : 'Field' ,
51
+ name : { kind : 'Name' , value : rootFieldName } ,
52
+ selectionSet : selections ? { kind : 'SelectionSet' , selections } : undefined ,
53
53
}
54
54
55
+ fieldNodes . push ( fieldNode )
56
+
55
57
const parentType = {
56
58
query : ( ) => schema . getQueryType ( ) ,
57
59
mutation : ( ) => schema . getMutationType ( ) ! ,
0 commit comments