Skip to content

Commit

Permalink
Fixed INPUT_FIELD_DEFAULT_MISMATCH (#104)
Browse files Browse the repository at this point in the history
* Fixed `INPUT_FIELD_DEFAULT_MISMATCH`

* Adds example

* Fixed indentation

* Fix format
  • Loading branch information
PascalSenn authored Feb 6, 2025
1 parent 005b55d commit 530de66
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions spec/Section 4 -- Composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand All @@ -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
Expand All @@ -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:

Expand Down

0 comments on commit 530de66

Please sign in to comment.