Skip to content
Prev Previous commit
Next Next commit
fix indentation
  • Loading branch information
yaacovCR committed Sep 21, 2024
commit 20f873459d42d420c0874f7c9a666c59b118e817
308 changes: 154 additions & 154 deletions src/execution/__tests__/variables-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1144,189 +1144,189 @@ describe('Execute: Handles inputs', () => {
},
});
});
});

it('errors with OneOf Input Object with more than one field', () => {
const result = executeQuery(`
{
fieldWithOneOfObjectInput(input: { a: "abc", b: 123 })
}
`);

expectJSON(result).toDeepEqual({
data: {
fieldWithOneOfObjectInput: null,
},
errors: [
it('errors with OneOf Input Object with more than one field', () => {
const result = executeQuery(`
{
message:
'Argument "input" of type "TestOneOfInputObject" has invalid value { a: "abc", b: 123 }.',
path: ['fieldWithOneOfObjectInput'],
locations: [{ line: 3, column: 42 }],
fieldWithOneOfObjectInput(input: { a: "abc", b: 123 })
}
`);

expectJSON(result).toDeepEqual({
data: {
fieldWithOneOfObjectInput: null,
},
],
errors: [
{
message:
'Argument "input" of type "TestOneOfInputObject" has invalid value { a: "abc", b: 123 }.',
path: ['fieldWithOneOfObjectInput'],
locations: [{ line: 3, column: 44 }],
},
],
});
});
});

it('errors with OneOf Input Object with a single null value', () => {
const result = executeQuery(`
{
fieldWithOneOfObjectInput(input: { a: null })
}
`);

expectJSON(result).toDeepEqual({
data: {
fieldWithOneOfObjectInput: null,
},
errors: [
it('errors with OneOf Input Object with a single null value', () => {
const result = executeQuery(`
{
message:
'Argument "input" of type "TestOneOfInputObject" has invalid value { a: null }.',
path: ['fieldWithOneOfObjectInput'],
locations: [{ line: 3, column: 42 }],
fieldWithOneOfObjectInput(input: { a: null })
}
`);

expectJSON(result).toDeepEqual({
data: {
fieldWithOneOfObjectInput: null,
},
],
errors: [
{
message:
'Argument "input" of type "TestOneOfInputObject" has invalid value { a: null }.',
path: ['fieldWithOneOfObjectInput'],
locations: [{ line: 3, column: 44 }],
},
],
});
});
});

it('errors with OneOf Input Object with multiple values, only one non-null', () => {
const result = executeQuery(`
{
fieldWithOneOfObjectInput(input: { a: "abc", b: null })
}
`);

expectJSON(result).toDeepEqual({
data: {
fieldWithOneOfObjectInput: null,
},
errors: [
it('errors with OneOf Input Object with multiple values, only one non-null', () => {
const result = executeQuery(`
{
message:
'Argument "input" of type "TestOneOfInputObject" has invalid value { a: "abc", b: null }.',
path: ['fieldWithOneOfObjectInput'],
locations: [{ line: 3, column: 42 }],
fieldWithOneOfObjectInput(input: { a: "abc", b: null })
}
`);

expectJSON(result).toDeepEqual({
data: {
fieldWithOneOfObjectInput: null,
},
],
errors: [
{
message:
'Argument "input" of type "TestOneOfInputObject" has invalid value { a: "abc", b: null }.',
path: ['fieldWithOneOfObjectInput'],
locations: [{ line: 3, column: 44 }],
},
],
});
});
});

it('allows a variable for the entire OneOf Object with a single value', () => {
const result = executeQuery(
`
query ($input: TestOneOfInputObject) {
fieldWithOneOfObjectInput(input: $input)
}
`,
{ input: { a: 'abc' } },
);
it('allows a variable for the entire OneOf Object with a single value', () => {
const result = executeQuery(
`
query ($input: TestOneOfInputObject) {
fieldWithOneOfObjectInput(input: $input)
}
`,
{ input: { a: 'abc' } },
);

expectJSON(result).toDeepEqual({
data: {
fieldWithOneOfObjectInput: '{ a: "abc" }',
},
expectJSON(result).toDeepEqual({
data: {
fieldWithOneOfObjectInput: '{ a: "abc" }',
},
});
});
});

it('allows a variable for the entire OneOf Object with a single defined value', () => {
const result = executeQuery(
`
query ($input: TestOneOfInputObject) {
fieldWithOneOfObjectInput(input: $input)
}
`,
{ input: { a: 'abc', b: undefined } },
);
it('allows a variable for the entire OneOf Object with a single defined value', () => {
const result = executeQuery(
`
query ($input: TestOneOfInputObject) {
fieldWithOneOfObjectInput(input: $input)
}
`,
{ input: { a: 'abc', b: undefined } },
);

expectJSON(result).toDeepEqual({
data: {
fieldWithOneOfObjectInput: '{ a: "abc" }',
},
expectJSON(result).toDeepEqual({
data: {
fieldWithOneOfObjectInput: '{ a: "abc" }',
},
});
});
});

it('errors with variable with no value', () => {
const result = executeQuery(
`
query ($input: TestOneOfInputObject) {
fieldWithOneOfObjectInput(input: $input)
}
`,
{ input: {} },
);
it('errors with variable with no value', () => {
const result = executeQuery(
`
query ($input: TestOneOfInputObject) {
fieldWithOneOfObjectInput(input: $input)
}
`,
{ input: {} },
);

expectJSON(result).toDeepEqual({
errors: [
{
message:
'Variable "$input" got invalid value {}; Within OneOf Input Object type "TestOneOfInputObject", exactly one field must be specified, and the value for that field must be non-null.',
locations: [{ line: 2, column: 16 }],
},
],
expectJSON(result).toDeepEqual({
errors: [
{
message:
'Variable "$input" got invalid value {}; Within OneOf Input Object type "TestOneOfInputObject", exactly one field must be specified, and the value for that field must be non-null.',
locations: [{ line: 2, column: 18 }],
},
],
});
});
});

it('errors with variable with multiple values', () => {
const result = executeQuery(
`
query ($input: TestOneOfInputObject) {
fieldWithOneOfObjectInput(input: $input)
}
`,
{ input: { a: 'abc', b: 123 } },
);
it('errors with variable with multiple values', () => {
const result = executeQuery(
`
query ($input: TestOneOfInputObject) {
fieldWithOneOfObjectInput(input: $input)
}
`,
{ input: { a: 'abc', b: 123 } },
);

expectJSON(result).toDeepEqual({
errors: [
{
message:
'Variable "$input" got invalid value { a: "abc", b: 123 }; Within OneOf Input Object type "TestOneOfInputObject", exactly one field must be specified, and the value for that field must be non-null.',
locations: [{ line: 2, column: 16 }],
},
],
expectJSON(result).toDeepEqual({
errors: [
{
message:
'Variable "$input" got invalid value { a: "abc", b: 123 }; Within OneOf Input Object type "TestOneOfInputObject", exactly one field must be specified, and the value for that field must be non-null.',
locations: [{ line: 2, column: 18 }],
},
],
});
});
});

it('errors with variable with single null value', () => {
const result = executeQuery(
`
query ($input: TestOneOfInputObject) {
fieldWithOneOfObjectInput(input: $input)
}
`,
{ input: { a: null } },
);
it('errors with variable with single null value', () => {
const result = executeQuery(
`
query ($input: TestOneOfInputObject) {
fieldWithOneOfObjectInput(input: $input)
}
`,
{ input: { a: null } },
);

expectJSON(result).toDeepEqual({
errors: [
{
message:
'Variable "$input" got invalid value null at "input.a"; Within OneOf Input Object type "TestOneOfInputObject", exactly one field must be specified, and the value for that field must be non-null.',
locations: [{ line: 2, column: 16 }],
},
],
expectJSON(result).toDeepEqual({
errors: [
{
message:
'Variable "$input" got invalid value null at "input.a"; Within OneOf Input Object type "TestOneOfInputObject", exactly one field must be specified, and the value for that field must be non-null.',
locations: [{ line: 2, column: 18 }],
},
],
});
});
});

it('errors with variable with multiple values, only one non-null', () => {
const result = executeQuery(
`
query ($input: TestOneOfInputObject) {
fieldWithOneOfObjectInput(input: $input)
}
`,
{ input: { a: 'abc', b: null } },
);
it('errors with variable with multiple values, only one non-null', () => {
const result = executeQuery(
`
query ($input: TestOneOfInputObject) {
fieldWithOneOfObjectInput(input: $input)
}
`,
{ input: { a: 'abc', b: null } },
);

expectJSON(result).toDeepEqual({
errors: [
{
message:
'Variable "$input" got invalid value { a: "abc", b: null }; Within OneOf Input Object type "TestOneOfInputObject", exactly one field must be specified, and the value for that field must be non-null.',
locations: [{ line: 2, column: 16 }],
},
],
expectJSON(result).toDeepEqual({
errors: [
{
message:
'Variable "$input" got invalid value { a: "abc", b: null }; Within OneOf Input Object type "TestOneOfInputObject", exactly one field must be specified, and the value for that field must be non-null.',
locations: [{ line: 2, column: 18 }],
},
],
});
});
});

Expand Down