@@ -21,10 +21,6 @@ import {
2121import { Source } from '../source.js' ;
2222import { TokenKind } from '../tokenKind.js' ;
2323
24- function parseCCN ( source : string ) {
25- return parse ( source , { experimentalClientControlledNullability : true } ) ;
26- }
27-
2824function expectSyntaxError ( text : string ) {
2925 return expectToThrowJSON ( ( ) => parse ( text ) ) ;
3026}
@@ -184,7 +180,7 @@ describe('Parser', () => {
184180 } ) ;
185181
186182 it ( 'parses kitchen sink' , ( ) => {
187- expect ( ( ) => parseCCN ( kitchenSinkQuery ) ) . to . not . throw ( ) ;
183+ expect ( ( ) => parse ( kitchenSinkQuery ) ) . to . not . throw ( ) ;
188184 } ) ;
189185
190186 it ( 'allows non-keywords anywhere a Name is allowed' , ( ) => {
@@ -255,206 +251,6 @@ describe('Parser', () => {
255251 ) . to . not . throw ( ) ;
256252 } ) ;
257253
258- it ( 'parses required field' , ( ) => {
259- const result = parseCCN ( '{ requiredField! }' ) ;
260-
261- expectJSON ( result ) . toDeepNestedProperty (
262- 'definitions[0].selectionSet.selections[0].nullabilityAssertion' ,
263- {
264- kind : Kind . NON_NULL_ASSERTION ,
265- loc : { start : 15 , end : 16 } ,
266- nullabilityAssertion : undefined ,
267- } ,
268- ) ;
269- } ) ;
270-
271- it ( 'parses optional field' , ( ) => {
272- expect ( ( ) => parseCCN ( '{ optionalField? }' ) ) . to . not . throw ( ) ;
273- } ) ;
274-
275- it ( 'does not parse field with multiple designators' , ( ) => {
276- expect ( ( ) => parseCCN ( '{ optionalField?! }' ) ) . to . throw (
277- 'Syntax Error: Expected Name, found "!".' ,
278- ) ;
279-
280- expect ( ( ) => parseCCN ( '{ optionalField!? }' ) ) . to . throw (
281- 'Syntax Error: Expected Name, found "?".' ,
282- ) ;
283- } ) ;
284-
285- it ( 'parses required with alias' , ( ) => {
286- expect ( ( ) => parseCCN ( '{ requiredField: field! }' ) ) . to . not . throw ( ) ;
287- } ) ;
288-
289- it ( 'parses optional with alias' , ( ) => {
290- expect ( ( ) => parseCCN ( '{ requiredField: field? }' ) ) . to . not . throw ( ) ;
291- } ) ;
292-
293- it ( 'does not parse aliased field with bang on left of colon' , ( ) => {
294- expect ( ( ) => parseCCN ( '{ requiredField!: field }' ) ) . to . throw ( ) ;
295- } ) ;
296-
297- it ( 'does not parse aliased field with question mark on left of colon' , ( ) => {
298- expect ( ( ) => parseCCN ( '{ requiredField?: field }' ) ) . to . throw ( ) ;
299- } ) ;
300-
301- it ( 'does not parse aliased field with bang on left and right of colon' , ( ) => {
302- expect ( ( ) => parseCCN ( '{ requiredField!: field! }' ) ) . to . throw ( ) ;
303- } ) ;
304-
305- it ( 'does not parse aliased field with question mark on left and right of colon' , ( ) => {
306- expect ( ( ) => parseCCN ( '{ requiredField?: field? }' ) ) . to . throw ( ) ;
307- } ) ;
308-
309- it ( 'does not parse designator on query' , ( ) => {
310- expect ( ( ) => parseCCN ( 'query? { field }' ) ) . to . throw ( ) ;
311- } ) ;
312-
313- it ( 'parses required within fragment' , ( ) => {
314- expect ( ( ) =>
315- parseCCN ( 'fragment MyFragment on Query { field! }' ) ,
316- ) . to . not . throw ( ) ;
317- } ) ;
318-
319- it ( 'parses optional within fragment' , ( ) => {
320- expect ( ( ) =>
321- parseCCN ( 'fragment MyFragment on Query { field? }' ) ,
322- ) . to . not . throw ( ) ;
323- } ) ;
324-
325- it ( 'parses field with required list elements' , ( ) => {
326- const result = parseCCN ( '{ field[!] }' ) ;
327-
328- expectJSON ( result ) . toDeepNestedProperty (
329- 'definitions[0].selectionSet.selections[0].nullabilityAssertion' ,
330- {
331- kind : Kind . LIST_NULLABILITY_OPERATOR ,
332- loc : { start : 7 , end : 10 } ,
333- nullabilityAssertion : {
334- kind : Kind . NON_NULL_ASSERTION ,
335- loc : { start : 8 , end : 9 } ,
336- nullabilityAssertion : undefined ,
337- } ,
338- } ,
339- ) ;
340- } ) ;
341-
342- it ( 'parses field with optional list elements' , ( ) => {
343- const result = parseCCN ( '{ field[?] }' ) ;
344-
345- expectJSON ( result ) . toDeepNestedProperty (
346- 'definitions[0].selectionSet.selections[0].nullabilityAssertion' ,
347- {
348- kind : Kind . LIST_NULLABILITY_OPERATOR ,
349- loc : { start : 7 , end : 10 } ,
350- nullabilityAssertion : {
351- kind : Kind . ERROR_BOUNDARY ,
352- loc : { start : 8 , end : 9 } ,
353- nullabilityAssertion : undefined ,
354- } ,
355- } ,
356- ) ;
357- } ) ;
358-
359- it ( 'parses field with required list' , ( ) => {
360- const result = parseCCN ( '{ field[]! }' ) ;
361-
362- expectJSON ( result ) . toDeepNestedProperty (
363- 'definitions[0].selectionSet.selections[0].nullabilityAssertion' ,
364- {
365- kind : Kind . NON_NULL_ASSERTION ,
366- loc : { start : 7 , end : 10 } ,
367- nullabilityAssertion : {
368- kind : Kind . LIST_NULLABILITY_OPERATOR ,
369- loc : { start : 7 , end : 9 } ,
370- nullabilityAssertion : undefined ,
371- } ,
372- } ,
373- ) ;
374- } ) ;
375-
376- it ( 'parses field with optional list' , ( ) => {
377- const result = parseCCN ( '{ field[]? }' ) ;
378-
379- expectJSON ( result ) . toDeepNestedProperty (
380- 'definitions[0].selectionSet.selections[0].nullabilityAssertion' ,
381- {
382- kind : Kind . ERROR_BOUNDARY ,
383- loc : { start : 7 , end : 10 } ,
384- nullabilityAssertion : {
385- kind : Kind . LIST_NULLABILITY_OPERATOR ,
386- loc : { start : 7 , end : 9 } ,
387- nullabilityAssertion : undefined ,
388- } ,
389- } ,
390- ) ;
391- } ) ;
392-
393- it ( 'parses multidimensional field with mixed list elements' , ( ) => {
394- const result = parseCCN ( '{ field[[[?]!]]! }' ) ;
395-
396- expectJSON ( result ) . toDeepNestedProperty (
397- 'definitions[0].selectionSet.selections[0].nullabilityAssertion' ,
398- {
399- kind : Kind . NON_NULL_ASSERTION ,
400- loc : { start : 7 , end : 16 } ,
401- nullabilityAssertion : {
402- kind : Kind . LIST_NULLABILITY_OPERATOR ,
403- loc : { start : 7 , end : 15 } ,
404- nullabilityAssertion : {
405- kind : Kind . LIST_NULLABILITY_OPERATOR ,
406- loc : { start : 8 , end : 14 } ,
407- nullabilityAssertion : {
408- kind : Kind . NON_NULL_ASSERTION ,
409- loc : { start : 9 , end : 13 } ,
410- nullabilityAssertion : {
411- kind : Kind . LIST_NULLABILITY_OPERATOR ,
412- loc : { start : 9 , end : 12 } ,
413- nullabilityAssertion : {
414- kind : Kind . ERROR_BOUNDARY ,
415- loc : { start : 10 , end : 11 } ,
416- nullabilityAssertion : undefined ,
417- } ,
418- } ,
419- } ,
420- } ,
421- } ,
422- } ,
423- ) ;
424- } ) ;
425-
426- it ( 'does not parse field with unbalanced brackets' , ( ) => {
427- expect ( ( ) => parseCCN ( '{ field[[] }' ) ) . to . throw (
428- 'Syntax Error: Expected "]", found "}".' ,
429- ) ;
430-
431- expect ( ( ) => parseCCN ( '{ field[]] }' ) ) . to . throw (
432- 'Syntax Error: Expected Name, found "]".' ,
433- ) ;
434-
435- expect ( ( ) => parse ( '{ field] }' ) ) . to . throw (
436- 'Syntax Error: Expected Name, found "]".' ,
437- ) ;
438-
439- expect ( ( ) => parseCCN ( '{ field[ }' ) ) . to . throw (
440- 'Syntax Error: Expected "]", found "}".' ,
441- ) ;
442- } ) ;
443-
444- it ( 'does not parse field with assorted invalid nullability designators' , ( ) => {
445- expect ( ( ) => parseCCN ( '{ field[][] }' ) ) . to . throw (
446- 'Syntax Error: Expected Name, found "[".' ,
447- ) ;
448-
449- expect ( ( ) => parseCCN ( '{ field[!!] }' ) ) . to . throw (
450- 'Syntax Error: Expected "]", found "!".' ,
451- ) ;
452-
453- expect ( ( ) => parseCCN ( '{ field[]?! }' ) ) . to . throw (
454- 'Syntax Error: Expected Name, found "!".' ,
455- ) ;
456- } ) ;
457-
458254 it ( 'creates ast' , ( ) => {
459255 const result = parse ( dedent `
460256 {
@@ -506,7 +302,6 @@ describe('Parser', () => {
506302 loc : { start : 9 , end : 14 } ,
507303 } ,
508304 ] ,
509- nullabilityAssertion : undefined ,
510305 directives : [ ] ,
511306 selectionSet : {
512307 kind : Kind . SELECTION_SET ,
@@ -522,7 +317,6 @@ describe('Parser', () => {
522317 value : 'id' ,
523318 } ,
524319 arguments : [ ] ,
525- nullabilityAssertion : undefined ,
526320 directives : [ ] ,
527321 selectionSet : undefined ,
528322 } ,
@@ -536,7 +330,6 @@ describe('Parser', () => {
536330 value : 'name' ,
537331 } ,
538332 arguments : [ ] ,
539- nullabilityAssertion : undefined ,
540333 directives : [ ] ,
541334 selectionSet : undefined ,
542335 } ,
@@ -585,7 +378,6 @@ describe('Parser', () => {
585378 value : 'node' ,
586379 } ,
587380 arguments : [ ] ,
588- nullabilityAssertion : undefined ,
589381 directives : [ ] ,
590382 selectionSet : {
591383 kind : Kind . SELECTION_SET ,
@@ -601,7 +393,6 @@ describe('Parser', () => {
601393 value : 'id' ,
602394 } ,
603395 arguments : [ ] ,
604- nullabilityAssertion : undefined ,
605396 directives : [ ] ,
606397 selectionSet : undefined ,
607398 } ,
@@ -656,7 +447,6 @@ describe('Parser', () => {
656447 value : 'node' ,
657448 } ,
658449 arguments : [ ] ,
659- nullabilityAssertion : undefined ,
660450 directives : [ ] ,
661451 selectionSet : {
662452 kind : Kind . SELECTION_SET ,
@@ -672,7 +462,6 @@ describe('Parser', () => {
672462 value : 'id' ,
673463 } ,
674464 arguments : [ ] ,
675- nullabilityAssertion : undefined ,
676465 directives : [ ] ,
677466 selectionSet : undefined ,
678467 } ,
@@ -1290,7 +1079,6 @@ describe('Parser', () => {
12901079 loc : { start : 150 , end : 155 } ,
12911080 } ,
12921081 ] ,
1293- nullabilityAssertion : undefined ,
12941082 directives : [ ] ,
12951083 selectionSet : undefined ,
12961084 loc : { start : 137 , end : 156 } ,
0 commit comments