@@ -3,6 +3,7 @@ import { describe, it } from 'mocha';
33
44import type {
55 GraphQLEnumType ,
6+ GraphQLField ,
67 GraphQLInputObjectType ,
78 GraphQLObjectType ,
89} from '../../type/definition.js' ;
@@ -71,16 +72,10 @@ describe('resolveSchemaCoordinate', () => {
7172 ) ;
7273
7374 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.' ,
7576 ) ;
7677 } ) ;
7778
78- it ( 'does not resolve meta-fields' , ( ) => {
79- expect (
80- resolveSchemaCoordinate ( schema , 'Business.__typename' ) ,
81- ) . to . deep . equal ( undefined ) ;
82- } ) ;
83-
8479 it ( 'resolves a Input Field' , ( ) => {
8580 const type = schema . getType ( 'SearchCriteria' ) as GraphQLInputObjectType ;
8681 const inputField = type . getFields ( ) . filter ;
@@ -101,15 +96,15 @@ describe('resolveSchemaCoordinate', () => {
10196 const type = schema . getType ( 'SearchFilter' ) as GraphQLEnumType ;
10297 const enumValue = type . getValue ( 'OPEN_NOW' ) ;
10398 expect (
104- resolveSchemaCoordinate ( schema , 'SearchFilter:: OPEN_NOW' ) ,
99+ resolveSchemaCoordinate ( schema , 'SearchFilter. OPEN_NOW' ) ,
105100 ) . to . deep . equal ( {
106101 kind : 'EnumValue' ,
107102 type,
108103 enumValue,
109104 } ) ;
110105
111106 expect (
112- resolveSchemaCoordinate ( schema , 'SearchFilter:: UNKNOWN' ) ,
107+ resolveSchemaCoordinate ( schema , 'SearchFilter. UNKNOWN' ) ,
113108 ) . to . deep . equal ( undefined ) ;
114109 } ) ;
115110
@@ -186,4 +181,59 @@ describe('resolveSchemaCoordinate', () => {
186181 'Expected "unknown" to be defined as a directive in the schema.' ,
187182 ) ;
188183 } ) ;
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+ } ) ;
189239} ) ;
0 commit comments