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 Types mergeable validation rule #45

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
76 changes: 76 additions & 0 deletions spec/Section 4 -- Composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,82 @@ run in sequence to produce the composite execution schema.

### Pre Merge Validation

#### Input Field Types mergeable

**Error Code**

`INPUT_FIELD_TYPES_NOT_MERGEABLE`

**Formal Specification**

- Let {fieldsByName} be a map of field lists where the key is the name of a
field and the value is a list of fields from mergeable input types from
different source schemas with the same name.
- For each {fields} in {fieldsByName}:
- {InputFieldsAreMergeable(fields)} must be true.

InputFieldsAreMergeable(fields):

- Given each pair of members {fieldA} and {fieldB} in {fields}:
- Let {typeA} be the type of {fieldA}.
- Let {typeB} be the type of {fieldB}.
- {SameTypeShape(typeA, typeB)} must be true.
Copy link
Member Author

Choose a reason for hiding this comment

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

this is wrong


**Explanatory Text**

The input fields of input objects with the same name must be mergeable. This
rule ensures that input objects with the same name in different source schemas
have fields that can be merged consistently without conflicts.

Input fields are considered mergeable when they share the same name and have
compatible types. The compatibility of types is determined by their structure
(e.g., lists), excluding nullability. Mergeable input fields with different
nullability are considered mergeable, and the resulting merged field will be the
most permissive of the two.

In this example, the field `field` in `Input1` has compatible types across
source schemas, making them mergeable:

```graphql example
input Input1 {
field: String!
}

input Input1 {
field: String
}
```

The following example shows that fields are mergeable if they have different
nullability but the named type is the same and the list structure is the same.

```graphql example
input Input1 {
tags: [String!]
}

input Input1 {
tags: [String]!
}

input Input1 {
tags: [String]
}
```

In this example, the field `field` on `Input1` is not mergeable as the field has
different named types (`String` and `DateTime`) across source schemas:

```graphql counter-example
input Input1 {
field: String!
}

input Input1 {
field: DateTime!
}
```

### Merge

### Post Merge Validation
Expand Down
Loading