@@ -109,17 +109,17 @@ describe('Graphql', () => {
109109 it ( 'function query' , ( ) => {
110110 const tpl = graphql . query ( {
111111 hello : types . number ,
112- hi : types . fn ( [ 'a_Int ' ] , {
112+ hi : types . fn ( [ 'a: Int! ' ] , {
113113 how : types . undefined . string ,
114114 are : {
115115 you : types . boolean ,
116116 } ,
117117 } ) ,
118- body : types . fn ( [ 'b_Int ' ] , types . boolean ) . include ( 'c_Boolean ' ) ,
118+ body : types . fn ( [ 'b: Int ' ] , types . boolean ) . include ( 'c: Boolean ' ) ,
119119 } ) ;
120120
121- expect ( tpl ( { a_Int : 3 , b_Int : 3 , c_Boolean : true } ) . query ) . to . equal (
122- `query Hello ($a: Int, $b: Int, $c: Boolean) {
121+ expect ( tpl ( { a : 3 , b : 3 , c : true } ) . query ) . to . equal (
122+ `query Hello ($a: Int! , $b: Int, $c: Boolean) {
123123 hello
124124 hi (a: $a) {
125125 how
@@ -134,6 +134,7 @@ describe('Graphql', () => {
134134
135135 it ( 'wrong function parameter name' , ( ) => {
136136 const tpl = graphql . query ( {
137+ // @ts -expect-error
137138 hello : types . fn ( [ 'a' ] , { } ) ,
138139 } ) ;
139140
@@ -142,18 +143,18 @@ describe('Graphql', () => {
142143
143144 it ( 'function with duplicate parameter' , ( ) => {
144145 const tpl = graphql . query ( {
145- hello : types . fn ( [ 'a_Int ' , 'b_String ' ] , {
146+ hello : types . fn ( [ 'a: Int ' , 'b: String ' ] , {
146147 id : types . number ,
147148 } ) ,
148- hi : types . fn ( [ 'a_Int ' , 'b_String ' ] , {
149+ hi : types . fn ( [ 'a: Int ' , 'b: String ' ] , {
149150 how : types . undefined . string ,
150151 are : {
151152 you : types . boolean ,
152153 } ,
153154 } ) ,
154155 } ) ;
155156
156- expect ( tpl ( { a_Int : 3 , b_String : '2' } ) . query ) . to . equal (
157+ expect ( tpl ( { a : 3 , b : '2' } ) . query ) . to . equal (
157158`query Hello ($a: Int, $b: String) {
158159 hello (a: $a, b: $b) {
159160 id
@@ -171,15 +172,15 @@ describe('Graphql', () => {
171172 it ( 'function parameter with alias variable' , ( ) => {
172173 const tpl = graphql . query ( {
173174 hello : types . number ,
174- hi : types . fn ( [ 'other:a_Int ' , 'b_String ' ] , {
175+ hi : types . fn ( [ 'a as other: Int ' , 'b: String ' ] , {
175176 how : types . undefined . string ,
176177 are : {
177178 you : types . boolean ,
178179 } ,
179180 } ) ,
180181 } ) ;
181182
182- expect ( tpl ( { ' other:a_Int' : 3 , b_String : '666' } ) . query ) . to . equal (
183+ expect ( tpl ( { other : 3 , b : '666' } ) . query ) . to . equal (
183184`query Hello ($other: Int, $b: String) {
184185 hello
185186 hi (a: $other, b: $b) {
@@ -191,21 +192,21 @@ describe('Graphql', () => {
191192}`
192193 ) ;
193194
194- expect ( tpl ( { ' other:a_Int' : 3 , b_String : '666' } ) . variables ) . to . contain ( {
195+ expect ( tpl ( { other : 3 , b : '666' } ) . variables ) . to . contain ( {
195196 other : 3 ,
196197 b : '666' ,
197198 } ) ;
198199 } ) ;
199200
200201 it ( 'function returns boolean, number or string' , ( ) => {
201202 const tpl = graphql . query ( {
202- hello : types . fn ( [ 'a_Int ' ] , types . boolean ) ,
203- hi : types . fn ( [ 'a_Int ' ] , types . number ) ,
204- how : types . fn ( [ 'a_Int ' ] , types . string ) ,
205- are : types . fn ( [ 'a_Int ' ] , types . number . string . undefined . null ) ,
203+ hello : types . fn ( [ 'a: Int ' ] , types . boolean ) ,
204+ hi : types . fn ( [ 'a: Int ' ] , types . number ) ,
205+ how : types . fn ( [ 'a: Int ' ] , types . string ) ,
206+ are : types . fn ( [ 'a: Int ' ] , types . number . string . undefined . null ) ,
206207 } ) ;
207208
208- expect ( tpl ( { a_Int : 3 } ) . query ) . to . equal (
209+ expect ( tpl ( { a : 3 } ) . query ) . to . equal (
209210`query Hello ($a: Int) {
210211 hello (a: $a)
211212 hi (a: $a)
@@ -222,12 +223,12 @@ describe('Graphql', () => {
222223 how : types . aliasOf ( 'who' ) . object ( {
223224 are : types . boolean ,
224225 } ) ,
225- list : types . aliasOf ( 'result' ) . fn ( [ 'a_Int ' ] , {
226+ list : types . aliasOf ( 'result' ) . fn ( [ 'a: Int ' ] , {
226227 id : types . number ,
227228 } ) ,
228229 } ) ;
229230
230- expect ( tpl ( { a_Int : 0 } ) . query ) . to . equal (
231+ expect ( tpl ( { a : 0 } ) . query ) . to . equal (
231232`query Hello ($a: Int) {
232233 hello: h
233234 hi: hii
@@ -442,7 +443,7 @@ fragment customUserFragment on User {
442443 it ( 'fragment includes function' , ( ) => {
443444 const fragment = graphql . fragment ( 'User' , {
444445 id : types . number ,
445- name : types . fn ( [ 'id_Int ' ] , {
446+ name : types . fn ( [ 'id: Int ' ] , {
446447 name : types . string ,
447448 } ) ,
448449 } ) ;
@@ -456,7 +457,7 @@ fragment customUserFragment on User {
456457 }
457458 } ) ;
458459
459- expect ( tpl ( { id_Int : 0 } ) . query ) . to . equal (
460+ expect ( tpl ( { id : 0 } ) . query ) . to . equal (
460461`query Hello ($id: Int) {
461462 hello
462463 hi
@@ -478,7 +479,7 @@ fragment UserFragment on User {
478479 it ( 'fragment in fragment' , ( ) => {
479480 const fragment = graphql . fragment ( 'User' , {
480481 id : types . number ,
481- fn1 : types . fn ( [ 'a_Int ' ] , types . number ) ,
482+ fn1 : types . fn ( [ 'a: Int ' ] , types . number ) ,
482483 } ) ;
483484
484485 const fragment1 = graphql . fragment ( 'Admin' , {
@@ -498,7 +499,7 @@ fragment UserFragment on User {
498499 } ) ;
499500
500501 expect ( tpl ( {
501- a_Int : 2 ,
502+ a : 2 ,
502503 } ) . query ) . to . equal (
503504`query Hello ($a: Int) {
504505 hello {
@@ -530,15 +531,15 @@ fragment AdminFragment on Admin {
530531 id : types . number ,
531532 ...types . on ( 'Admin' , {
532533 name : types . string ,
533- fn1 : types . fn ( [ 'b_Int ' ] , {
534+ fn1 : types . fn ( [ 'b: Int ' ] , {
534535 id : types . number ,
535536 } ) ,
536537 } ) ,
537538 } )
538539 }
539540 } ) ;
540541
541- expect ( tpl ( { b_Int : 2 } ) . query ) . to . equal (
542+ expect ( tpl ( { b : 2 } ) . query ) . to . equal (
542543`query Hello ($b: Int) {
543544 hello {
544545 ... on User {
@@ -557,24 +558,24 @@ fragment AdminFragment on Admin {
557558
558559 it ( 'directives' , ( ) => {
559560 const tpl = graphql . query ( {
560- hello : types . number . include ( 'b_Boolean ' ) ,
561- hi : types . include ( 'b_Boolean ' ) . skip ( 'c_Boolean ' ) . fn ( [ 'a_Int ' ] , {
561+ hello : types . number . include ( 'b:Boolean ' ) ,
562+ hi : types . include ( 'b:Boolean ' ) . skip ( 'c:Boolean ' ) . fn ( [ 'a: Int ' ] , {
562563 how : types . undefined . string ,
563564 are : {
564565 you : types . boolean ,
565566 } ,
566567 } ) ,
567- ...types . include ( 'd_Boolean ' ) . on ( 'User' , {
568+ ...types . include ( 'd:Boolean ' ) . on ( 'User' , {
568569 name : types . string ,
569570 } ) ,
570- ...types . include ( 'f_Boolean ' ) . on ( 'User' , {
571+ ...types . include ( 'f:Boolean ' ) . on ( 'User' , {
571572 lists : {
572573 id : types . number ,
573574 }
574575 } ) ,
575576 } ) ;
576577
577- expect ( tpl ( { a_Int : 3 , b_Boolean : false , c_Boolean : true , d_Boolean : true , f_Boolean : true } ) . query ) . to . equal (
578+ expect ( tpl ( { a : 3 , b : false , c : true , d : true , f : true } ) . query ) . to . equal (
578579`query Hello ($b: Boolean, $c: Boolean, $a: Int, $d: Boolean, $f: Boolean) {
579580 hello @include(if: $b)
580581 hi (a: $a) @include(if: $b) @skip(if: $c) {
0 commit comments