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 With Missing Required Fields #41

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

### Pre Merge Validation

#### **Input With Missing Required Fields**

**Error Code:**

REQUIRED_INPUT_FIELD_MISSING_IN_SOME_SUBGRAPH

**Severity:**

ERROR

**Formal Specification:**

- Let {typeNames} be the set of all input object types from all source schemas that are not declared as `@inaccessible`.
- For each {typeName} in {typeNames}:
- Let `{types}` be the list of all input object types from different source schemas with the name {typeName}.
- `{AreTypesConsistent(types)}` must be true.

**Function Definition:**

`AreTypesConsistent(inputs):`

- Let `{requiredFields}` be the intersection of all required field names across all input objects in `{inputs}`.
- For each `{input}` in `{inputs}`:
- Let `{inputFields}` be the set of all field names in of required fields in `{input}`.
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
- Let `{inputFields}` be the set of all field names in of required fields in `{input}`.
- Let `{inputFields}` be the set of all field names of required fields in `{input}`.

- `{inputFields}` must equal `{requiredFields}`.

**Explanatory Text**

Input types are merged by intersection, meaning that the merged input type will have all fields that are present in all input types with the same name.
This rule ensures that input object types with the same name across different subgraphs share a consistent set of required fields.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we reverting to "subgraph" naming again?


When an input object is defined across multiple subgraphs, this rule ensures that any required field present in one subgraph is present in all others defining the input object.
This allows for reliable usage of input objects in queries across subgraphs.

### Examples

**Valid Example:**

If all subgraphs define `Input1` with the required field `field1`, the rule is satisfied:

```graphql
# Subgraph 1
input Input1 {
field1: String!
field2: String
}

# Subgraph 2
input Input1 {
field1: String!
field3: Int
}
```

**Invalid Example:**

If `field1` is required in one subgraph but missing in another, this violates the rule:

```graphql
# Subgraph 1
input Input1 {
field1: String!
field2: String
}

# Subgraph 2
input Input1 {
field2: String
field3: Int
}
```

In this invalid case, `field1` is mandatory in `Subgraph 1` but not defined in `Subgraph 2`, causing inconsistency in required fields across subgraphs.

PascalSenn marked this conversation as resolved.
Show resolved Hide resolved
### Merge

### Post Merge Validation
Expand Down