@@ -214,30 +214,38 @@ func FieldsOnCorrectTypeRule(context *ValidationContext) *ValidationRuleInstance
214
214
var result interface {}
215
215
if node , ok := p .Node .(* ast.Field ); ok {
216
216
ttype := context .ParentType ()
217
+ if ttype == nil {
218
+ return action , result
219
+ }
220
+ if t , ok := ttype .(* Object ); ok && t == nil {
221
+ return action , result
222
+ }
223
+ if t , ok := ttype .(* Interface ); ok && t == nil {
224
+ return action , result
225
+ }
226
+ if t , ok := ttype .(* Union ); ok && t == nil {
227
+ return action , result
228
+ }
229
+ fieldDef := context .FieldDef ()
230
+ if fieldDef == nil {
231
+ // This field doesn't exist, lets look for suggestions.
232
+ nodeName := ""
233
+ if node .Name != nil {
234
+ nodeName = node .Name .Value
235
+ }
236
+ // First determine if there are any suggested types to condition on.
237
+ suggestedTypeNames := getSuggestedTypeNames (context .Schema (), ttype , nodeName )
217
238
218
- if ttype != nil {
219
- fieldDef := context .FieldDef ()
220
- if fieldDef == nil {
221
- // This field doesn't exist, lets look for suggestions.
222
- nodeName := ""
223
- if node .Name != nil {
224
- nodeName = node .Name .Value
225
- }
226
- // First determine if there are any suggested types to condition on.
227
- suggestedTypeNames := getSuggestedTypeNames (context .Schema (), ttype , nodeName )
228
-
229
- // If there are no suggested types, then perhaps this was a typo?
230
- suggestedFieldNames := []string {}
231
- if len (suggestedTypeNames ) == 0 {
232
- suggestedFieldNames = getSuggestedFieldNames (context .Schema (), ttype , nodeName )
233
- }
234
-
235
- reportError (
236
- context ,
237
- UndefinedFieldMessage (nodeName , ttype .Name (), suggestedTypeNames , suggestedFieldNames ),
238
- []ast.Node {node },
239
- )
239
+ // If there are no suggested types, then perhaps this was a typo?
240
+ suggestedFieldNames := []string {}
241
+ if len (suggestedTypeNames ) == 0 {
242
+ suggestedFieldNames = getSuggestedFieldNames (context .Schema (), ttype , nodeName )
240
243
}
244
+ reportError (
245
+ context ,
246
+ UndefinedFieldMessage (nodeName , ttype .Name (), suggestedTypeNames , suggestedFieldNames ),
247
+ []ast.Node {node },
248
+ )
241
249
}
242
250
}
243
251
return action , result
@@ -1721,6 +1729,9 @@ func VariablesInAllowedPositionRule(context *ValidationContext) *ValidationRuleI
1721
1729
func isValidLiteralValue (ttype Input , valueAST ast.Value ) (bool , []string ) {
1722
1730
// A value must be provided if the type is non-null.
1723
1731
if ttype , ok := ttype .(* NonNull ); ok {
1732
+ if e := ttype .Error (); e != nil {
1733
+ return false , []string {e .Error ()}
1734
+ }
1724
1735
if valueAST == nil {
1725
1736
if ttype .OfType .Name () != "" {
1726
1737
return false , []string {fmt .Sprintf (`Expected "%v!", found null.` , ttype .OfType .Name ())}
0 commit comments