Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/validation/__tests__/KnownTypeNamesRule-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Validate: Known type names', () => {

it('unknown type names are invalid', () => {
expectErrors(`
query Foo($var: JumbledUpLetters) {
query Foo($var: [JumbledUpLetters!]!) {
user(id: 4) {
name
pets { ... on Badger { name }, ...PetFields }
Expand All @@ -65,7 +65,7 @@ describe('Validate: Known type names', () => {
`).to.deep.equal([
{
message: 'Unknown type "JumbledUpLetters".',
locations: [{ line: 2, column: 23 }],
locations: [{ line: 2, column: 24 }],
},
{
message: 'Unknown type "Badger".',
Expand Down
8 changes: 8 additions & 0 deletions src/validation/__tests__/VariablesAreInputTypesRule-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ function expectValid(queryStr: string) {
}

describe('Validate: Variables are input types', () => {
it('unknown types are ignored', () => {
expectValid(`
query Foo($a: Unknown, $b: [[Unknown!]]!) {
field(a: $a, b: $b)
}
`);
});

it('input types are valid', () => {
expectValid(`
query Foo($a: String, $b: [Boolean!]!, $c: ComplexInput) {
Expand Down
2 changes: 1 addition & 1 deletion src/validation/rules/VariablesAreInputTypesRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function VariablesAreInputTypesRule(
VariableDefinition(node: VariableDefinitionNode) {
const type = typeFromAST(context.getSchema(), node.type);

if (type && !isInputType(type)) {
if (type !== undefined && !isInputType(type)) {
const variableName = node.variable.name.value;
const typeName = print(node.type);

Expand Down