From 3d3080459e725ef16f1057b13144a6ce1aeb93af Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Fri, 21 Jun 2024 15:37:37 +0100 Subject: [PATCH] __Type.isOneOf is implemented on __Type so isn't specific to input objects --- src/utilities/__tests__/getIntrospectionQuery-test.ts | 4 ++-- src/utilities/getIntrospectionQuery.ts | 8 ++++---- src/utilities/introspectionFromSchema.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/utilities/__tests__/getIntrospectionQuery-test.ts b/src/utilities/__tests__/getIntrospectionQuery-test.ts index b8e59fcd0c..b57950841b 100644 --- a/src/utilities/__tests__/getIntrospectionQuery-test.ts +++ b/src/utilities/__tests__/getIntrospectionQuery-test.ts @@ -120,9 +120,9 @@ describe('getIntrospectionQuery', () => { it('include "isOneOf" field on input objects', () => { expectIntrospectionQuery().toNotMatch('isOneOf'); - expectIntrospectionQuery({ inputObjectOneOf: true }).toMatch('isOneOf', 1); + expectIntrospectionQuery({ oneOf: true }).toMatch('isOneOf', 1); - expectIntrospectionQuery({ inputObjectOneOf: false }).toNotMatch('isOneOf'); + expectIntrospectionQuery({ oneOf: false }).toNotMatch('isOneOf'); }); it('include deprecated input field and args', () => { diff --git a/src/utilities/getIntrospectionQuery.ts b/src/utilities/getIntrospectionQuery.ts index 2305a8cc8b..fb6c65b4fe 100644 --- a/src/utilities/getIntrospectionQuery.ts +++ b/src/utilities/getIntrospectionQuery.ts @@ -37,7 +37,7 @@ export interface IntrospectionOptions { * Whether target GraphQL server supports `@oneOf` input objects. * Default: false */ - inputObjectOneOf?: boolean; + oneOf?: boolean; } /** @@ -51,7 +51,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string { directiveIsRepeatable: false, schemaDescription: false, inputValueDeprecation: false, - inputObjectOneOf: false, + oneOf: false, ...options, }; @@ -69,7 +69,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string { function inputDeprecation(str: string) { return optionsWithDefault.inputValueDeprecation ? str : ''; } - const inputObjectOneOf = optionsWithDefault.inputObjectOneOf ? 'isOneOf' : ''; + const oneOf = optionsWithDefault.oneOf ? 'isOneOf' : ''; return ` query IntrospectionQuery { @@ -98,7 +98,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string { name ${descriptions} ${specifiedByUrl} - ${inputObjectOneOf} + ${oneOf} fields(includeDeprecated: true) { name ${descriptions} diff --git a/src/utilities/introspectionFromSchema.ts b/src/utilities/introspectionFromSchema.ts index f4ae3f7512..375d53f119 100644 --- a/src/utilities/introspectionFromSchema.ts +++ b/src/utilities/introspectionFromSchema.ts @@ -30,7 +30,7 @@ export function introspectionFromSchema( directiveIsRepeatable: true, schemaDescription: true, inputValueDeprecation: true, - inputObjectOneOf: true, + oneOf: true, ...options, };