From 530de667bb1f853c8bf471fc925b26a8ecf6fed0 Mon Sep 17 00:00:00 2001 From: PascalSenn Date: Thu, 6 Feb 2025 17:06:19 +0100 Subject: [PATCH] Fixed `INPUT_FIELD_DEFAULT_MISMATCH` (#104) * Fixed `INPUT_FIELD_DEFAULT_MISMATCH` * Adds example * Fixed indentation * Fix format --- spec/Section 4 -- Composition.md | 39 +++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index 0e3ed7d..1955208 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -2491,16 +2491,17 @@ type User { - Let {defaultValues} be a set containing the default values of each input field in {inputFields}. - If the size of {defaultValues} is greater than 1: - - {InputFieldsHaveConsistentDefaults(inputFields)} must be false. + - {InputFieldsHaveConsistentDefaults(inputFields)} must be {true}. InputFieldsHaveConsistentDefaults(inputFields): - Given each pair of input fields {inputFieldA} and {inputFieldB} in {inputFields}: - - If the default value of {inputFieldA} is not equal to the default value of - {inputFieldB}: - - return false -- return true + - If {inputFieldA} has a default value and {inputFieldB} has a default value: + - If the default value of {inputFieldA} is not equal to the default value of + {inputFieldB}: + - return {false} +- return {true} **Explanatory Text** @@ -2513,7 +2514,7 @@ different source schemas will result in a schema composition error. **Examples** -In the the following example both source schemas have an input field `field1` +In the the following example both source schemas have an input field `genre` with the same default value. This is valid: ```graphql example @@ -2539,6 +2540,32 @@ enum Genre { } ``` +If only one of the source schemas defines a default value for a given input +field, the composition is still valid: + +```graphql example +# Schema A + +input BookFilter { + genre: Genre +} + +enum Genre { + FANTASY + SCIENCE_FICTION +} + +# Schema B +input BookFilter { + genre: Genre = FANTASY +} + +enum Genre { + FANTASY + SCIENCE_FICTION +} +``` + In the following example both source schemas define an input field `minPageCount` with different default values. This is invalid: