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

Adds Input Field Default Mismatch Rule #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
71 changes: 71 additions & 0 deletions spec/Section 4 -- Composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,77 @@ run in sequence to produce the composite execution schema.

### Pre Merge Validation

#### Input Field Default Mismatch

**Error Code**

`Input_Field_Default_Mismatch`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`Input_Field_Default_Mismatch`
`INPUT_FIELD_DEFAULT_MISMATCH`


**Formal Specification**

- Let {inputFieldsByName} be a map where the key is the name of an input field
and the value is a list of input fields from different source schemas from the same
type with the same name.
- For each {inputFields} in {inputFieldsByName}:
- Let {defaultValues} be a set containing the default values of each input
field in {inputFields}.
- If the size of {defaultValues} is greater than
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greater than what? 🙂

- {InputFieldsHaveConsistentDefaults(inputFields)} must be false.

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

**Explanatory Text**

Input fields in different source schemas that have the same name are required to have
consistent default values. This ensures that there is no ambiguity or
inconsistency when merging schemas from different source schemas.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inconsistency when merging schemas from different source schemas.
inconsistency when merging input fields from different source schemas.


A mismatch in default values for input fields with the same name across
different source schemas will result in a schema composition error.

In the the following example both source schemas have an input field `field1` with
the same default value. This is valid:

```graphql example
input Filter {
field1: Enum1 = Value1
}

enum Enum1 {
Value1
Value2
}

input Filter {
field1: Enum1 = Value1
}

enum Enum1 {
Value1
Value2
}
Comment on lines +56 to +72
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
input Filter {
field1: Enum1 = Value1
}
enum Enum1 {
Value1
Value2
}
input Filter {
field1: Enum1 = Value1
}
enum Enum1 {
Value1
Value2
}
input Filter {
field1: Enum1 = VALUE1
}
enum Enum1 {
VALUE1
VALUE2
}
input Filter {
field1: Enum1 = VALUE1
}
enum Enum1 {
VALUE1
VALUE2
}

```

In the following example both source schemas define an input field `field1` with
different default values. This is invalid:

```graphql counter-example
input Filter {
field1: Int = 10
}

input Filter {
field1: Int = 20
}
```

### Merge

### Post Merge Validation
Expand Down
Loading