Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CCN #3999

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/__testUtils__/kitchenSinkQuery.ts
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
Expand Up @@ -232,7 +232,6 @@ export {
isDefinitionNode,
isExecutableDefinitionNode,
isSelectionNode,
isNullabilityAssertionNode,
isValueNode,
isConstValueNode,
isTypeNode,
Expand Down Expand Up @@ -264,10 +263,6 @@ export type {
SelectionNode,
FieldNode,
ArgumentNode,
NullabilityAssertionNode,
NonNullAssertionNode,
ErrorBoundaryNode,
ListNullabilityOperatorNode,
ConstArgumentNode,
FragmentSpreadNode,
InlineFragmentNode,
Expand Down
8 changes: 0 additions & 8 deletions src/language/__tests__/lexer-test.ts
Expand Up @@ -936,13 +936,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 @@ -1188,7 +1181,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
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
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
Expand Up @@ -199,14 +199,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 @@ -225,19 +223,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