@@ -10,11 +10,11 @@ import { Kind } from '../../language/kinds';
10
10
11
11
import type { ValidationContext } from '../ValidationContext' ;
12
12
import type { ExecutionContext } from '../../execution/execute' ;
13
- import { collectFields } from '../../execution/execute' ;
14
-
15
- function fakeResolver ( ) {
16
- /* noop */
17
- }
13
+ import {
14
+ collectFields ,
15
+ defaultFieldResolver ,
16
+ defaultTypeResolver ,
17
+ } from '../../execution/execute' ;
18
18
19
19
/**
20
20
* Subscriptions must only include a non-introspection field.
@@ -50,8 +50,8 @@ export function SingleFieldSubscriptionsRule(
50
50
contextValue : undefined ,
51
51
operation : node ,
52
52
variableValues,
53
- fieldResolver : fakeResolver ,
54
- typeResolver : fakeResolver ,
53
+ fieldResolver : defaultFieldResolver ,
54
+ typeResolver : defaultTypeResolver ,
55
55
errors : [ ] ,
56
56
} ;
57
57
const fields = collectFields (
@@ -78,18 +78,16 @@ export function SingleFieldSubscriptionsRule(
78
78
}
79
79
for ( const responseKey of Object . keys ( fields ) ) {
80
80
const field = fields [ responseKey ] [ 0 ] ;
81
- if ( field ) {
82
- const fieldName = field . name . value ;
83
- if ( fieldName [ 0 ] === '_' && fieldName [ 1 ] === '_' ) {
84
- context . reportError (
85
- new GraphQLError (
86
- operationName != null
87
- ? `Subscription "${ operationName } " must not select an introspection top level field.`
88
- : 'Anonymous Subscription must not select an introspection top level field.' ,
89
- fields [ responseKey ] ,
90
- ) ,
91
- ) ;
92
- }
81
+ const fieldName = field . name . value ;
82
+ if ( fieldName [ 0 ] === '_' && fieldName [ 1 ] === '_' ) {
83
+ context . reportError (
84
+ new GraphQLError (
85
+ operationName != null
86
+ ? `Subscription "${ operationName } " must not select an introspection top level field.`
87
+ : 'Anonymous Subscription must not select an introspection top level field.' ,
88
+ fields [ responseKey ] ,
89
+ ) ,
90
+ ) ;
93
91
}
94
92
}
95
93
}
0 commit comments