@@ -1133,8 +1133,8 @@ func (r *rpcPlanningContext) buildCompositeField(inlineFragmentNode ast.Node, fr
11331133 result := make ([]RPCField , 0 , len (fieldRefs ))
11341134
11351135 for _ , fieldRef := range fieldRefs {
1136- fieldDef , found := r .fieldDefinitionForType (r .operation .FieldNameString (fieldRef ), fragmentSelection .typeName )
1137- if ! found {
1136+ fieldDef := r .fieldDefinitionForType (r .operation .FieldNameString (fieldRef ), fragmentSelection .typeName )
1137+ if fieldDef == ast . InvalidRef {
11381138 return nil , fmt .Errorf ("unable to build composite field: field definition not found for field %s" , r .operation .FieldNameString (fieldRef ))
11391139 }
11401140
@@ -1162,13 +1162,18 @@ func (r *rpcPlanningContext) buildCompositeField(inlineFragmentNode ast.Node, fr
11621162 return result , nil
11631163}
11641164
1165- func (r * rpcPlanningContext ) fieldDefinitionForType (fieldName , typeName string ) ( ref int , exists bool ) {
1165+ func (r * rpcPlanningContext ) fieldDefinitionForType (fieldName , typeName string ) int {
11661166 node , found := r .definition .NodeByNameStr (typeName )
11671167 if ! found {
1168- return ast .InvalidRef , false
1168+ return ast .InvalidRef
1169+ }
1170+
1171+ if ref , found := r .definition .NodeFieldDefinitionByName (node , unsafebytes .StringToBytes (fieldName )); found {
1172+ return ref
11691173 }
11701174
1171- return r .definition .NodeFieldDefinitionByName (node , unsafebytes .StringToBytes (fieldName ))
1175+ return ast .InvalidRef
1176+
11721177}
11731178
11741179// createResolverRPCCalls creates a new call for each resolved field.
0 commit comments