Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed INPUT_FIELD_DEFAULT_MISMATCH #104

Merged
merged 5 commits into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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