@@ -32,9 +32,10 @@ export function buildInfoForAllScalars(
3232 const fieldNodes : FieldNode [ ] = [ ]
3333 const type = getTypeForRootFieldName ( rootFieldName , operation , schema )
3434
35+ let selections : FieldNode [ ] | undefined
3536 if ( type instanceof GraphQLObjectType ) {
3637 const fields = type . getFields ( )
37- const selections = Object . keys ( fields )
38+ selections = Object . keys ( fields )
3839 . filter ( f => isScalar ( fields [ f ] . type ) )
3940 . map < FieldNode > ( fieldName => {
4041 const field = fields [ fieldName ]
@@ -43,15 +44,16 @@ export function buildInfoForAllScalars(
4344 name : { kind : 'Name' , value : field . name } ,
4445 }
4546 } )
46- const fieldNode : FieldNode = {
47- kind : 'Field' ,
48- name : { kind : 'Name' , value : rootFieldName } ,
49- selectionSet : { kind : 'SelectionSet' , selections } ,
50- }
47+ }
5148
52- fieldNodes . push ( fieldNode )
49+ const fieldNode : FieldNode = {
50+ kind : 'Field' ,
51+ name : { kind : 'Name' , value : rootFieldName } ,
52+ selectionSet : selections ? { kind : 'SelectionSet' , selections } : undefined ,
5353 }
5454
55+ fieldNodes . push ( fieldNode )
56+
5557 const parentType = {
5658 query : ( ) => schema . getQueryType ( ) ,
5759 mutation : ( ) => schema . getMutationType ( ) ! ,
0 commit comments