@@ -3,6 +3,7 @@ import { describe, it } from 'mocha';
3
3
4
4
import type {
5
5
GraphQLEnumType ,
6
+ GraphQLField ,
6
7
GraphQLInputObjectType ,
7
8
GraphQLObjectType ,
8
9
} from '../../type/definition.js' ;
@@ -71,16 +72,10 @@ describe('resolveSchemaCoordinate', () => {
71
72
) ;
72
73
73
74
expect ( ( ) => resolveSchemaCoordinate ( schema , 'String.field' ) ) . to . throw (
74
- 'Expected "String" to be an Input Object, Object or Interface type.' ,
75
+ 'Expected "String" to be an Enum, Input Object, Object or Interface type.' ,
75
76
) ;
76
77
} ) ;
77
78
78
- it ( 'does not resolve meta-fields' , ( ) => {
79
- expect (
80
- resolveSchemaCoordinate ( schema , 'Business.__typename' ) ,
81
- ) . to . deep . equal ( undefined ) ;
82
- } ) ;
83
-
84
79
it ( 'resolves a Input Field' , ( ) => {
85
80
const type = schema . getType ( 'SearchCriteria' ) as GraphQLInputObjectType ;
86
81
const inputField = type . getFields ( ) . filter ;
@@ -101,15 +96,15 @@ describe('resolveSchemaCoordinate', () => {
101
96
const type = schema . getType ( 'SearchFilter' ) as GraphQLEnumType ;
102
97
const enumValue = type . getValue ( 'OPEN_NOW' ) ;
103
98
expect (
104
- resolveSchemaCoordinate ( schema , 'SearchFilter:: OPEN_NOW' ) ,
99
+ resolveSchemaCoordinate ( schema , 'SearchFilter. OPEN_NOW' ) ,
105
100
) . to . deep . equal ( {
106
101
kind : 'EnumValue' ,
107
102
type,
108
103
enumValue,
109
104
} ) ;
110
105
111
106
expect (
112
- resolveSchemaCoordinate ( schema , 'SearchFilter:: UNKNOWN' ) ,
107
+ resolveSchemaCoordinate ( schema , 'SearchFilter. UNKNOWN' ) ,
113
108
) . to . deep . equal ( undefined ) ;
114
109
} ) ;
115
110
@@ -186,4 +181,59 @@ describe('resolveSchemaCoordinate', () => {
186
181
'Expected "unknown" to be defined as a directive in the schema.' ,
187
182
) ;
188
183
} ) ;
184
+
185
+ it ( 'resolves a meta-field' , ( ) => {
186
+ const type = schema . getType ( 'Business' ) as GraphQLObjectType ;
187
+ const field = schema . getField ( type , '__typename' ) ;
188
+ expect (
189
+ resolveSchemaCoordinate ( schema , 'Business.__typename' ) ,
190
+ ) . to . deep . equal ( {
191
+ kind : 'Field' ,
192
+ type,
193
+ field,
194
+ } ) ;
195
+ } ) ;
196
+
197
+ it ( 'resolves a meta-field argument' , ( ) => {
198
+ const type = schema . getType ( 'Query' ) as GraphQLObjectType ;
199
+ const field = schema . getField ( type , '__type' ) as GraphQLField ;
200
+ const fieldArgument = field . args . find ( ( arg ) => arg . name === 'name' ) ;
201
+ expect (
202
+ resolveSchemaCoordinate ( schema , 'Query.__type(name:)' ) ,
203
+ ) . to . deep . equal ( {
204
+ kind : 'FieldArgument' ,
205
+ type,
206
+ field,
207
+ fieldArgument,
208
+ } ) ;
209
+ } ) ;
210
+
211
+ it ( 'resolves an Introspection Type' , ( ) => {
212
+ expect ( resolveSchemaCoordinate ( schema , '__Type' ) ) . to . deep . equal ( {
213
+ kind : 'NamedType' ,
214
+ type : schema . getType ( '__Type' ) ,
215
+ } ) ;
216
+ } ) ;
217
+
218
+ it ( 'resolves an Introspection Type Field' , ( ) => {
219
+ const type = schema . getType ( '__Directive' ) as GraphQLObjectType ;
220
+ const field = type . getFields ( ) . name ;
221
+ expect ( resolveSchemaCoordinate ( schema , '__Directive.name' ) ) . to . deep . equal ( {
222
+ kind : 'Field' ,
223
+ type,
224
+ field,
225
+ } ) ;
226
+ } ) ;
227
+
228
+ it ( 'resolves an Introspection Type Enum Value' , ( ) => {
229
+ const type = schema . getType ( '__DirectiveLocation' ) as GraphQLEnumType ;
230
+ const enumValue = type . getValue ( 'INLINE_FRAGMENT' ) ;
231
+ expect (
232
+ resolveSchemaCoordinate ( schema , '__DirectiveLocation.INLINE_FRAGMENT' ) ,
233
+ ) . to . deep . equal ( {
234
+ kind : 'EnumValue' ,
235
+ type,
236
+ enumValue,
237
+ } ) ;
238
+ } ) ;
189
239
} ) ;
0 commit comments