From b9f3333f7480fc01ee2d54b9ff4e1971d28ca161 Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Wed, 27 Mar 2024 13:32:46 +0200 Subject: [PATCH 1/2] oneof: add test case --- src/execution/__tests__/oneof-test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/execution/__tests__/oneof-test.ts b/src/execution/__tests__/oneof-test.ts index af0e0580ab..eb73709da4 100644 --- a/src/execution/__tests__/oneof-test.ts +++ b/src/execution/__tests__/oneof-test.ts @@ -134,6 +134,30 @@ describe('Execute: Handles OneOf Input Objects', () => { }); }); + it('accepts multiple variable key as long as only one has a value', () => { + // NOTE: This is an *invalid* query, but it should be an *executable* query. + const query = ` + query ($a: String) { + test(input: { a: $a, b: $b }) { + a + b + } + } + `; + const result = executeQuery(query, rootValue, { + a: 'abc', + }); + + expectJSON(result).toDeepEqual({ + data: { + test: { + a: 'abc', + b: null, + }, + }, + }); + }); + it('rejects a variable with multiple non-null keys', () => { const query = ` query ($input: TestInputObject!) { From bbb82b65b23ce9a871603e0d435886bb4ce38925 Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Sat, 7 Sep 2024 21:07:55 +0300 Subject: [PATCH 2/2] demonstrate better test problem --- src/execution/__tests__/oneof-test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/execution/__tests__/oneof-test.ts b/src/execution/__tests__/oneof-test.ts index eb73709da4..eda808d246 100644 --- a/src/execution/__tests__/oneof-test.ts +++ b/src/execution/__tests__/oneof-test.ts @@ -137,7 +137,7 @@ describe('Execute: Handles OneOf Input Objects', () => { it('accepts multiple variable key as long as only one has a value', () => { // NOTE: This is an *invalid* query, but it should be an *executable* query. const query = ` - query ($a: String) { + query ($a: String, $b: String) { test(input: { a: $a, b: $b }) { a b