@@ -8,7 +8,13 @@ import { kitchenSinkQuery } from '../../__testUtils__/kitchenSinkQuery';
88import  {  inspect  }  from  '../../jsutils/inspect' ; 
99
1010import  {  Kind  }  from  '../kinds' ; 
11- import  {  parse ,  parseConstValue ,  parseType ,  parseValue  }  from  '../parser' ; 
11+ import  { 
12+   parse , 
13+   parseConstValue , 
14+   parseSchemaCoordinate , 
15+   parseType , 
16+   parseValue , 
17+ }  from  '../parser' ; 
1218import  {  Source  }  from  '../source' ; 
1319import  {  TokenKind  }  from  '../tokenKind' ; 
1420
@@ -729,6 +735,180 @@ describe('Parser', () => {
729735    } ) ; 
730736  } ) ; 
731737
738+   describe ( 'parseSchemaCoordinate' ,  ( )  =>  { 
739+     it ( 'parses Name' ,  ( )  =>  { 
740+       const  result  =  parseSchemaCoordinate ( 'MyType' ) ; 
741+       expectJSON ( result ) . toDeepEqual ( { 
742+         kind : Kind . TYPE_COORDINATE , 
743+         loc : {  start : 0 ,  end : 6  } , 
744+         name : { 
745+           kind : Kind . NAME , 
746+           loc : {  start : 0 ,  end : 6  } , 
747+           value : 'MyType' , 
748+         } , 
749+       } ) ; 
750+     } ) ; 
751+ 
752+     it ( 'parses Name . Name' ,  ( )  =>  { 
753+       const  result  =  parseSchemaCoordinate ( 'MyType.field' ) ; 
754+       expectJSON ( result ) . toDeepEqual ( { 
755+         kind : Kind . MEMBER_COORDINATE , 
756+         loc : {  start : 0 ,  end : 12  } , 
757+         name : { 
758+           kind : Kind . NAME , 
759+           loc : {  start : 0 ,  end : 6  } , 
760+           value : 'MyType' , 
761+         } , 
762+         memberName : { 
763+           kind : Kind . NAME , 
764+           loc : {  start : 7 ,  end : 12  } , 
765+           value : 'field' , 
766+         } , 
767+       } ) ; 
768+     } ) ; 
769+ 
770+     it ( 'rejects Name . Name . Name' ,  ( )  =>  { 
771+       expect ( ( )  =>  parseSchemaCoordinate ( 'MyType.field.deep' ) ) 
772+         . to . throw ( ) 
773+         . to . deep . include ( { 
774+           message : 'Syntax Error: Expected <EOF>, found ".".' , 
775+           locations : [ {  line : 1 ,  column : 13  } ] , 
776+         } ) ; 
777+     } ) ; 
778+ 
779+     it ( 'parses Name . Name ( Name : )' ,  ( )  =>  { 
780+       const  result  =  parseSchemaCoordinate ( 'MyType.field(arg:)' ) ; 
781+       expectJSON ( result ) . toDeepEqual ( { 
782+         kind : Kind . ARGUMENT_COORDINATE , 
783+         loc : {  start : 0 ,  end : 18  } , 
784+         name : { 
785+           kind : Kind . NAME , 
786+           loc : {  start : 0 ,  end : 6  } , 
787+           value : 'MyType' , 
788+         } , 
789+         fieldName : { 
790+           kind : Kind . NAME , 
791+           loc : {  start : 7 ,  end : 12  } , 
792+           value : 'field' , 
793+         } , 
794+         argumentName : { 
795+           kind : Kind . NAME , 
796+           loc : {  start : 13 ,  end : 16  } , 
797+           value : 'arg' , 
798+         } , 
799+       } ) ; 
800+     } ) ; 
801+ 
802+     it ( 'rejects Name . Name ( Name : Name )' ,  ( )  =>  { 
803+       expect ( ( )  =>  parseSchemaCoordinate ( 'MyType.field(arg: value)' ) ) 
804+         . to . throw ( ) 
805+         . to . deep . include ( { 
806+           message : 'Syntax Error: Invalid character: " ".' , 
807+           locations : [ {  line : 1 ,  column : 18  } ] , 
808+         } ) ; 
809+     } ) ; 
810+ 
811+     it ( 'parses @ Name' ,  ( )  =>  { 
812+       const  result  =  parseSchemaCoordinate ( '@myDirective' ) ; 
813+       expectJSON ( result ) . toDeepEqual ( { 
814+         kind : Kind . DIRECTIVE_COORDINATE , 
815+         loc : {  start : 0 ,  end : 12  } , 
816+         name : { 
817+           kind : Kind . NAME , 
818+           loc : {  start : 1 ,  end : 12  } , 
819+           value : 'myDirective' , 
820+         } , 
821+       } ) ; 
822+     } ) ; 
823+ 
824+     it ( 'parses @ Name ( Name : )' ,  ( )  =>  { 
825+       const  result  =  parseSchemaCoordinate ( '@myDirective(arg:)' ) ; 
826+       expectJSON ( result ) . toDeepEqual ( { 
827+         kind : Kind . DIRECTIVE_ARGUMENT_COORDINATE , 
828+         loc : {  start : 0 ,  end : 18  } , 
829+         name : { 
830+           kind : Kind . NAME , 
831+           loc : {  start : 1 ,  end : 12  } , 
832+           value : 'myDirective' , 
833+         } , 
834+         argumentName : { 
835+           kind : Kind . NAME , 
836+           loc : {  start : 13 ,  end : 16  } , 
837+           value : 'arg' , 
838+         } , 
839+       } ) ; 
840+     } ) ; 
841+ 
842+     it ( 'parses __Type' ,  ( )  =>  { 
843+       const  result  =  parseSchemaCoordinate ( '__Type' ) ; 
844+       expectJSON ( result ) . toDeepEqual ( { 
845+         kind : Kind . TYPE_COORDINATE , 
846+         loc : {  start : 0 ,  end : 6  } , 
847+         name : { 
848+           kind : Kind . NAME , 
849+           loc : {  start : 0 ,  end : 6  } , 
850+           value : '__Type' , 
851+         } , 
852+       } ) ; 
853+     } ) ; 
854+ 
855+     it ( 'parses Type.__metafield' ,  ( )  =>  { 
856+       const  result  =  parseSchemaCoordinate ( 'Type.__metafield' ) ; 
857+       expectJSON ( result ) . toDeepEqual ( { 
858+         kind : Kind . MEMBER_COORDINATE , 
859+         loc : {  start : 0 ,  end : 16  } , 
860+         name : { 
861+           kind : Kind . NAME , 
862+           loc : {  start : 0 ,  end : 4  } , 
863+           value : 'Type' , 
864+         } , 
865+         memberName : { 
866+           kind : Kind . NAME , 
867+           loc : {  start : 5 ,  end : 16  } , 
868+           value : '__metafield' , 
869+         } , 
870+       } ) ; 
871+     } ) ; 
872+ 
873+     it ( 'parses Type.__metafield(arg:)' ,  ( )  =>  { 
874+       const  result  =  parseSchemaCoordinate ( 'Type.__metafield(arg:)' ) ; 
875+       expectJSON ( result ) . toDeepEqual ( { 
876+         kind : Kind . ARGUMENT_COORDINATE , 
877+         loc : {  start : 0 ,  end : 22  } , 
878+         name : { 
879+           kind : Kind . NAME , 
880+           loc : {  start : 0 ,  end : 4  } , 
881+           value : 'Type' , 
882+         } , 
883+         fieldName : { 
884+           kind : Kind . NAME , 
885+           loc : {  start : 5 ,  end : 16  } , 
886+           value : '__metafield' , 
887+         } , 
888+         argumentName : { 
889+           kind : Kind . NAME , 
890+           loc : {  start : 17 ,  end : 20  } , 
891+           value : 'arg' , 
892+         } , 
893+       } ) ; 
894+     } ) ; 
895+ 
896+     it ( 'rejects @ Name . Name' ,  ( )  =>  { 
897+       expect ( ( )  =>  parseSchemaCoordinate ( '@myDirective.field' ) ) 
898+         . to . throw ( ) 
899+         . to . deep . include ( { 
900+           message : 'Syntax Error: Expected <EOF>, found ".".' , 
901+           locations : [ {  line : 1 ,  column : 13  } ] , 
902+         } ) ; 
903+     } ) ; 
904+ 
905+     it ( 'accepts a Source object' ,  ( )  =>  { 
906+       expect ( parseSchemaCoordinate ( 'MyType' ) ) . to . deep . equal ( 
907+         parseSchemaCoordinate ( new  Source ( 'MyType' ) ) , 
908+       ) ; 
909+     } ) ; 
910+   } ) ; 
911+ 
732912  describe ( 'operation and variable definition descriptions' ,  ( )  =>  { 
733913    it ( 'parses operation with description and variable descriptions' ,  ( )  =>  { 
734914      const  result  =  parse ( dedent ` 
0 commit comments