@@ -15,10 +15,6 @@ import { parse, parseConstValue, parseType, parseValue } from '../parser.js';
1515import { Source } from '../source.js' ;
1616import { TokenKind } from '../tokenKind.js' ;
1717
18- function parseCCN ( source : string ) {
19- return parse ( source , { experimentalClientControlledNullability : true } ) ;
20- }
21-
2218function expectSyntaxError ( text : string ) {
2319 return expectToThrowJSON ( ( ) => parse ( text ) ) ;
2420}
@@ -173,7 +169,7 @@ describe('Parser', () => {
173169 } ) ;
174170
175171 it ( 'parses kitchen sink' , ( ) => {
176- expect ( ( ) => parseCCN ( kitchenSinkQuery ) ) . to . not . throw ( ) ;
172+ expect ( ( ) => parse ( kitchenSinkQuery ) ) . to . not . throw ( ) ;
177173 } ) ;
178174
179175 it ( 'allows non-keywords anywhere a Name is allowed' , ( ) => {
@@ -244,206 +240,6 @@ describe('Parser', () => {
244240 ) . to . not . throw ( ) ;
245241 } ) ;
246242
247- it ( 'parses required field' , ( ) => {
248- const result = parseCCN ( '{ requiredField! }' ) ;
249-
250- expectJSON ( result ) . toDeepNestedProperty (
251- 'definitions[0].selectionSet.selections[0].nullabilityAssertion' ,
252- {
253- kind : Kind . NON_NULL_ASSERTION ,
254- loc : { start : 15 , end : 16 } ,
255- nullabilityAssertion : undefined ,
256- } ,
257- ) ;
258- } ) ;
259-
260- it ( 'parses optional field' , ( ) => {
261- expect ( ( ) => parseCCN ( '{ optionalField? }' ) ) . to . not . throw ( ) ;
262- } ) ;
263-
264- it ( 'does not parse field with multiple designators' , ( ) => {
265- expect ( ( ) => parseCCN ( '{ optionalField?! }' ) ) . to . throw (
266- 'Syntax Error: Expected Name, found "!".' ,
267- ) ;
268-
269- expect ( ( ) => parseCCN ( '{ optionalField!? }' ) ) . to . throw (
270- 'Syntax Error: Expected Name, found "?".' ,
271- ) ;
272- } ) ;
273-
274- it ( 'parses required with alias' , ( ) => {
275- expect ( ( ) => parseCCN ( '{ requiredField: field! }' ) ) . to . not . throw ( ) ;
276- } ) ;
277-
278- it ( 'parses optional with alias' , ( ) => {
279- expect ( ( ) => parseCCN ( '{ requiredField: field? }' ) ) . to . not . throw ( ) ;
280- } ) ;
281-
282- it ( 'does not parse aliased field with bang on left of colon' , ( ) => {
283- expect ( ( ) => parseCCN ( '{ requiredField!: field }' ) ) . to . throw ( ) ;
284- } ) ;
285-
286- it ( 'does not parse aliased field with question mark on left of colon' , ( ) => {
287- expect ( ( ) => parseCCN ( '{ requiredField?: field }' ) ) . to . throw ( ) ;
288- } ) ;
289-
290- it ( 'does not parse aliased field with bang on left and right of colon' , ( ) => {
291- expect ( ( ) => parseCCN ( '{ requiredField!: field! }' ) ) . to . throw ( ) ;
292- } ) ;
293-
294- it ( 'does not parse aliased field with question mark on left and right of colon' , ( ) => {
295- expect ( ( ) => parseCCN ( '{ requiredField?: field? }' ) ) . to . throw ( ) ;
296- } ) ;
297-
298- it ( 'does not parse designator on query' , ( ) => {
299- expect ( ( ) => parseCCN ( 'query? { field }' ) ) . to . throw ( ) ;
300- } ) ;
301-
302- it ( 'parses required within fragment' , ( ) => {
303- expect ( ( ) =>
304- parseCCN ( 'fragment MyFragment on Query { field! }' ) ,
305- ) . to . not . throw ( ) ;
306- } ) ;
307-
308- it ( 'parses optional within fragment' , ( ) => {
309- expect ( ( ) =>
310- parseCCN ( 'fragment MyFragment on Query { field? }' ) ,
311- ) . to . not . throw ( ) ;
312- } ) ;
313-
314- it ( 'parses field with required list elements' , ( ) => {
315- const result = parseCCN ( '{ field[!] }' ) ;
316-
317- expectJSON ( result ) . toDeepNestedProperty (
318- 'definitions[0].selectionSet.selections[0].nullabilityAssertion' ,
319- {
320- kind : Kind . LIST_NULLABILITY_OPERATOR ,
321- loc : { start : 7 , end : 10 } ,
322- nullabilityAssertion : {
323- kind : Kind . NON_NULL_ASSERTION ,
324- loc : { start : 8 , end : 9 } ,
325- nullabilityAssertion : undefined ,
326- } ,
327- } ,
328- ) ;
329- } ) ;
330-
331- it ( 'parses field with optional list elements' , ( ) => {
332- const result = parseCCN ( '{ field[?] }' ) ;
333-
334- expectJSON ( result ) . toDeepNestedProperty (
335- 'definitions[0].selectionSet.selections[0].nullabilityAssertion' ,
336- {
337- kind : Kind . LIST_NULLABILITY_OPERATOR ,
338- loc : { start : 7 , end : 10 } ,
339- nullabilityAssertion : {
340- kind : Kind . ERROR_BOUNDARY ,
341- loc : { start : 8 , end : 9 } ,
342- nullabilityAssertion : undefined ,
343- } ,
344- } ,
345- ) ;
346- } ) ;
347-
348- it ( 'parses field with required list' , ( ) => {
349- const result = parseCCN ( '{ field[]! }' ) ;
350-
351- expectJSON ( result ) . toDeepNestedProperty (
352- 'definitions[0].selectionSet.selections[0].nullabilityAssertion' ,
353- {
354- kind : Kind . NON_NULL_ASSERTION ,
355- loc : { start : 7 , end : 10 } ,
356- nullabilityAssertion : {
357- kind : Kind . LIST_NULLABILITY_OPERATOR ,
358- loc : { start : 7 , end : 9 } ,
359- nullabilityAssertion : undefined ,
360- } ,
361- } ,
362- ) ;
363- } ) ;
364-
365- it ( 'parses field with optional list' , ( ) => {
366- const result = parseCCN ( '{ field[]? }' ) ;
367-
368- expectJSON ( result ) . toDeepNestedProperty (
369- 'definitions[0].selectionSet.selections[0].nullabilityAssertion' ,
370- {
371- kind : Kind . ERROR_BOUNDARY ,
372- loc : { start : 7 , end : 10 } ,
373- nullabilityAssertion : {
374- kind : Kind . LIST_NULLABILITY_OPERATOR ,
375- loc : { start : 7 , end : 9 } ,
376- nullabilityAssertion : undefined ,
377- } ,
378- } ,
379- ) ;
380- } ) ;
381-
382- it ( 'parses multidimensional field with mixed list elements' , ( ) => {
383- const result = parseCCN ( '{ field[[[?]!]]! }' ) ;
384-
385- expectJSON ( result ) . toDeepNestedProperty (
386- 'definitions[0].selectionSet.selections[0].nullabilityAssertion' ,
387- {
388- kind : Kind . NON_NULL_ASSERTION ,
389- loc : { start : 7 , end : 16 } ,
390- nullabilityAssertion : {
391- kind : Kind . LIST_NULLABILITY_OPERATOR ,
392- loc : { start : 7 , end : 15 } ,
393- nullabilityAssertion : {
394- kind : Kind . LIST_NULLABILITY_OPERATOR ,
395- loc : { start : 8 , end : 14 } ,
396- nullabilityAssertion : {
397- kind : Kind . NON_NULL_ASSERTION ,
398- loc : { start : 9 , end : 13 } ,
399- nullabilityAssertion : {
400- kind : Kind . LIST_NULLABILITY_OPERATOR ,
401- loc : { start : 9 , end : 12 } ,
402- nullabilityAssertion : {
403- kind : Kind . ERROR_BOUNDARY ,
404- loc : { start : 10 , end : 11 } ,
405- nullabilityAssertion : undefined ,
406- } ,
407- } ,
408- } ,
409- } ,
410- } ,
411- } ,
412- ) ;
413- } ) ;
414-
415- it ( 'does not parse field with unbalanced brackets' , ( ) => {
416- expect ( ( ) => parseCCN ( '{ field[[] }' ) ) . to . throw (
417- 'Syntax Error: Expected "]", found "}".' ,
418- ) ;
419-
420- expect ( ( ) => parseCCN ( '{ field[]] }' ) ) . to . throw (
421- 'Syntax Error: Expected Name, found "]".' ,
422- ) ;
423-
424- expect ( ( ) => parse ( '{ field] }' ) ) . to . throw (
425- 'Syntax Error: Expected Name, found "]".' ,
426- ) ;
427-
428- expect ( ( ) => parseCCN ( '{ field[ }' ) ) . to . throw (
429- 'Syntax Error: Expected "]", found "}".' ,
430- ) ;
431- } ) ;
432-
433- it ( 'does not parse field with assorted invalid nullability designators' , ( ) => {
434- expect ( ( ) => parseCCN ( '{ field[][] }' ) ) . to . throw (
435- 'Syntax Error: Expected Name, found "[".' ,
436- ) ;
437-
438- expect ( ( ) => parseCCN ( '{ field[!!] }' ) ) . to . throw (
439- 'Syntax Error: Expected "]", found "!".' ,
440- ) ;
441-
442- expect ( ( ) => parseCCN ( '{ field[]?! }' ) ) . to . throw (
443- 'Syntax Error: Expected Name, found "!".' ,
444- ) ;
445- } ) ;
446-
447243 it ( 'creates ast' , ( ) => {
448244 const result = parse ( dedent `
449245 {
@@ -494,7 +290,6 @@ describe('Parser', () => {
494290 loc : { start : 9 , end : 14 } ,
495291 } ,
496292 ] ,
497- nullabilityAssertion : undefined ,
498293 directives : [ ] ,
499294 selectionSet : {
500295 kind : Kind . SELECTION_SET ,
@@ -510,7 +305,6 @@ describe('Parser', () => {
510305 value : 'id' ,
511306 } ,
512307 arguments : [ ] ,
513- nullabilityAssertion : undefined ,
514308 directives : [ ] ,
515309 selectionSet : undefined ,
516310 } ,
@@ -524,7 +318,6 @@ describe('Parser', () => {
524318 value : 'name' ,
525319 } ,
526320 arguments : [ ] ,
527- nullabilityAssertion : undefined ,
528321 directives : [ ] ,
529322 selectionSet : undefined ,
530323 } ,
@@ -572,7 +365,6 @@ describe('Parser', () => {
572365 value : 'node' ,
573366 } ,
574367 arguments : [ ] ,
575- nullabilityAssertion : undefined ,
576368 directives : [ ] ,
577369 selectionSet : {
578370 kind : Kind . SELECTION_SET ,
@@ -588,7 +380,6 @@ describe('Parser', () => {
588380 value : 'id' ,
589381 } ,
590382 arguments : [ ] ,
591- nullabilityAssertion : undefined ,
592383 directives : [ ] ,
593384 selectionSet : undefined ,
594385 } ,
0 commit comments