Skip to content

Commit

Permalink
removal of experimental CCN
Browse files Browse the repository at this point in the history
  • Loading branch information
twof authored and yaacovCR committed Sep 26, 2024
1 parent bd2fe71 commit fb7bb98
Show file tree
Hide file tree
Showing 16 changed files with 5 additions and 704 deletions.
15 changes: 0 additions & 15 deletions src/__testUtils__/kitchenSinkQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,6 @@ query queryName($foo: ComplexType, $site: Site = MOBILE) @onQuery {
...frag @onFragmentSpread
}
}
field3!
field4?
requiredField5: field5!
requiredSelectionSet(first: 10)! @directive {
field
}
unsetListItemsRequiredList: listField[]!
requiredListItemsUnsetList: listField[!]
requiredListItemsRequiredList: listField[!]!
unsetListItemsOptionalList: listField[]?
optionalListItemsUnsetList: listField[?]
optionalListItemsOptionalList: listField[?]?
multidimensionalList: listField[[[!]!]!]!
}
... @skip(unless: $foo) {
id
Expand Down
5 changes: 0 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ export {
isDefinitionNode,
isExecutableDefinitionNode,
isSelectionNode,
isNullabilityAssertionNode,
isValueNode,
isConstValueNode,
isTypeNode,
Expand Down Expand Up @@ -266,10 +265,6 @@ export type {
FieldNode,
ArgumentNode,
FragmentArgumentNode,
NullabilityAssertionNode,
NonNullAssertionNode,
ErrorBoundaryNode,
ListNullabilityOperatorNode,
ConstArgumentNode,
FragmentSpreadNode,
InlineFragmentNode,
Expand Down
8 changes: 0 additions & 8 deletions src/language/__tests__/lexer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -944,13 +944,6 @@ describe('Lexer', () => {
value: undefined,
});

expect(lexOne('?')).to.contain({
kind: TokenKind.QUESTION_MARK,
start: 0,
end: 1,
value: undefined,
});

expect(lexOne('$')).to.contain({
kind: TokenKind.DOLLAR,
start: 0,
Expand Down Expand Up @@ -1196,7 +1189,6 @@ describe('isPunctuatorTokenKind', () => {

it('returns true for punctuator tokens', () => {
expect(isPunctuatorToken('!')).to.equal(true);
expect(isPunctuatorToken('?')).to.equal(true);
expect(isPunctuatorToken('$')).to.equal(true);
expect(isPunctuatorToken('&')).to.equal(true);
expect(isPunctuatorToken('(')).to.equal(true);
Expand Down
211 changes: 1 addition & 210 deletions src/language/__tests__/parser-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import { parse, parseConstValue, parseType, parseValue } from '../parser.js';
import { Source } from '../source.js';
import { TokenKind } from '../tokenKind.js';

function parseCCN(source: string) {
return parse(source, { experimentalClientControlledNullability: true });
}

function expectSyntaxError(text: string) {
return expectToThrowJSON(() => parse(text));
}
Expand Down Expand Up @@ -173,7 +169,7 @@ describe('Parser', () => {
});

it('parses kitchen sink', () => {
expect(() => parseCCN(kitchenSinkQuery)).to.not.throw();
expect(() => parse(kitchenSinkQuery)).to.not.throw();
});

it('allows non-keywords anywhere a Name is allowed', () => {
Expand Down Expand Up @@ -244,206 +240,6 @@ describe('Parser', () => {
).to.not.throw();
});

it('parses required field', () => {
const result = parseCCN('{ requiredField! }');

expectJSON(result).toDeepNestedProperty(
'definitions[0].selectionSet.selections[0].nullabilityAssertion',
{
kind: Kind.NON_NULL_ASSERTION,
loc: { start: 15, end: 16 },
nullabilityAssertion: undefined,
},
);
});

it('parses optional field', () => {
expect(() => parseCCN('{ optionalField? }')).to.not.throw();
});

it('does not parse field with multiple designators', () => {
expect(() => parseCCN('{ optionalField?! }')).to.throw(
'Syntax Error: Expected Name, found "!".',
);

expect(() => parseCCN('{ optionalField!? }')).to.throw(
'Syntax Error: Expected Name, found "?".',
);
});

it('parses required with alias', () => {
expect(() => parseCCN('{ requiredField: field! }')).to.not.throw();
});

it('parses optional with alias', () => {
expect(() => parseCCN('{ requiredField: field? }')).to.not.throw();
});

it('does not parse aliased field with bang on left of colon', () => {
expect(() => parseCCN('{ requiredField!: field }')).to.throw();
});

it('does not parse aliased field with question mark on left of colon', () => {
expect(() => parseCCN('{ requiredField?: field }')).to.throw();
});

it('does not parse aliased field with bang on left and right of colon', () => {
expect(() => parseCCN('{ requiredField!: field! }')).to.throw();
});

it('does not parse aliased field with question mark on left and right of colon', () => {
expect(() => parseCCN('{ requiredField?: field? }')).to.throw();
});

it('does not parse designator on query', () => {
expect(() => parseCCN('query? { field }')).to.throw();
});

it('parses required within fragment', () => {
expect(() =>
parseCCN('fragment MyFragment on Query { field! }'),
).to.not.throw();
});

it('parses optional within fragment', () => {
expect(() =>
parseCCN('fragment MyFragment on Query { field? }'),
).to.not.throw();
});

it('parses field with required list elements', () => {
const result = parseCCN('{ field[!] }');

expectJSON(result).toDeepNestedProperty(
'definitions[0].selectionSet.selections[0].nullabilityAssertion',
{
kind: Kind.LIST_NULLABILITY_OPERATOR,
loc: { start: 7, end: 10 },
nullabilityAssertion: {
kind: Kind.NON_NULL_ASSERTION,
loc: { start: 8, end: 9 },
nullabilityAssertion: undefined,
},
},
);
});

it('parses field with optional list elements', () => {
const result = parseCCN('{ field[?] }');

expectJSON(result).toDeepNestedProperty(
'definitions[0].selectionSet.selections[0].nullabilityAssertion',
{
kind: Kind.LIST_NULLABILITY_OPERATOR,
loc: { start: 7, end: 10 },
nullabilityAssertion: {
kind: Kind.ERROR_BOUNDARY,
loc: { start: 8, end: 9 },
nullabilityAssertion: undefined,
},
},
);
});

it('parses field with required list', () => {
const result = parseCCN('{ field[]! }');

expectJSON(result).toDeepNestedProperty(
'definitions[0].selectionSet.selections[0].nullabilityAssertion',
{
kind: Kind.NON_NULL_ASSERTION,
loc: { start: 7, end: 10 },
nullabilityAssertion: {
kind: Kind.LIST_NULLABILITY_OPERATOR,
loc: { start: 7, end: 9 },
nullabilityAssertion: undefined,
},
},
);
});

it('parses field with optional list', () => {
const result = parseCCN('{ field[]? }');

expectJSON(result).toDeepNestedProperty(
'definitions[0].selectionSet.selections[0].nullabilityAssertion',
{
kind: Kind.ERROR_BOUNDARY,
loc: { start: 7, end: 10 },
nullabilityAssertion: {
kind: Kind.LIST_NULLABILITY_OPERATOR,
loc: { start: 7, end: 9 },
nullabilityAssertion: undefined,
},
},
);
});

it('parses multidimensional field with mixed list elements', () => {
const result = parseCCN('{ field[[[?]!]]! }');

expectJSON(result).toDeepNestedProperty(
'definitions[0].selectionSet.selections[0].nullabilityAssertion',
{
kind: Kind.NON_NULL_ASSERTION,
loc: { start: 7, end: 16 },
nullabilityAssertion: {
kind: Kind.LIST_NULLABILITY_OPERATOR,
loc: { start: 7, end: 15 },
nullabilityAssertion: {
kind: Kind.LIST_NULLABILITY_OPERATOR,
loc: { start: 8, end: 14 },
nullabilityAssertion: {
kind: Kind.NON_NULL_ASSERTION,
loc: { start: 9, end: 13 },
nullabilityAssertion: {
kind: Kind.LIST_NULLABILITY_OPERATOR,
loc: { start: 9, end: 12 },
nullabilityAssertion: {
kind: Kind.ERROR_BOUNDARY,
loc: { start: 10, end: 11 },
nullabilityAssertion: undefined,
},
},
},
},
},
},
);
});

it('does not parse field with unbalanced brackets', () => {
expect(() => parseCCN('{ field[[] }')).to.throw(
'Syntax Error: Expected "]", found "}".',
);

expect(() => parseCCN('{ field[]] }')).to.throw(
'Syntax Error: Expected Name, found "]".',
);

expect(() => parse('{ field] }')).to.throw(
'Syntax Error: Expected Name, found "]".',
);

expect(() => parseCCN('{ field[ }')).to.throw(
'Syntax Error: Expected "]", found "}".',
);
});

it('does not parse field with assorted invalid nullability designators', () => {
expect(() => parseCCN('{ field[][] }')).to.throw(
'Syntax Error: Expected Name, found "[".',
);

expect(() => parseCCN('{ field[!!] }')).to.throw(
'Syntax Error: Expected "]", found "!".',
);

expect(() => parseCCN('{ field[]?! }')).to.throw(
'Syntax Error: Expected Name, found "!".',
);
});

it('creates ast', () => {
const result = parse(dedent`
{
Expand Down Expand Up @@ -494,7 +290,6 @@ describe('Parser', () => {
loc: { start: 9, end: 14 },
},
],
nullabilityAssertion: undefined,
directives: [],
selectionSet: {
kind: Kind.SELECTION_SET,
Expand All @@ -510,7 +305,6 @@ describe('Parser', () => {
value: 'id',
},
arguments: [],
nullabilityAssertion: undefined,
directives: [],
selectionSet: undefined,
},
Expand All @@ -524,7 +318,6 @@ describe('Parser', () => {
value: 'name',
},
arguments: [],
nullabilityAssertion: undefined,
directives: [],
selectionSet: undefined,
},
Expand Down Expand Up @@ -572,7 +365,6 @@ describe('Parser', () => {
value: 'node',
},
arguments: [],
nullabilityAssertion: undefined,
directives: [],
selectionSet: {
kind: Kind.SELECTION_SET,
Expand All @@ -588,7 +380,6 @@ describe('Parser', () => {
value: 'id',
},
arguments: [],
nullabilityAssertion: undefined,
directives: [],
selectionSet: undefined,
},
Expand Down
9 changes: 0 additions & 9 deletions src/language/__tests__/predicates-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
isConstValueNode,
isDefinitionNode,
isExecutableDefinitionNode,
isNullabilityAssertionNode,
isSelectionNode,
isTypeDefinitionNode,
isTypeExtensionNode,
Expand Down Expand Up @@ -63,14 +62,6 @@ describe('AST node predicates', () => {
]);
});

it('isNullabilityAssertionNode', () => {
expect(filterNodes(isNullabilityAssertionNode)).to.deep.equal([
'ListNullabilityOperator',
'NonNullAssertion',
'ErrorBoundary',
]);
});

it('isValueNode', () => {
expect(filterNodes(isValueNode)).to.deep.equal([
'Variable',
Expand Down
15 changes: 0 additions & 15 deletions src/language/__tests__/printer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,12 @@ describe('Printer: Query document', () => {
it('prints kitchen sink without altering ast', () => {
const ast = parse(kitchenSinkQuery, {
noLocation: true,
experimentalClientControlledNullability: true,
});

const astBeforePrintCall = JSON.stringify(ast);
const printed = print(ast);
const printedAST = parse(printed, {
noLocation: true,
experimentalClientControlledNullability: true,
});

expect(printedAST).to.deep.equal(ast);
Expand All @@ -253,19 +251,6 @@ describe('Printer: Query document', () => {
...frag @onFragmentSpread
}
}
field3!
field4?
requiredField5: field5!
requiredSelectionSet(first: 10)! @directive {
field
}
unsetListItemsRequiredList: listField[]!
requiredListItemsUnsetList: listField[!]
requiredListItemsRequiredList: listField[!]!
unsetListItemsOptionalList: listField[]?
optionalListItemsUnsetList: listField[?]
optionalListItemsOptionalList: listField[?]?
multidimensionalList: listField[[[!]!]!]!
}
... @skip(unless: $foo) {
id
Expand Down
Loading

0 comments on commit fb7bb98

Please sign in to comment.