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

Add enum types valuemust be the same across source schemas #42

Open
wants to merge 7 commits 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
67 changes: 67 additions & 0 deletions spec/Section 4 -- Composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,73 @@ run in sequence to produce the composite execution schema.

### Pre Merge Validation

#### Enum Type Values Must Be The Same Across Source Schemas

**Error Code**

ENUM_VALUES_MUST_BE_THE_SAME_ACROSS_SCHEMAS

**Formal Specification**

- Let {enumNames} be the set of all enum type names across all source schemas.
- For each {enumName} in {enumNames}:
- Let {enums} be the list of all enum types from different source schemas with the name {enumName}.
- {EnumsAreMergeable(enums)} must be true.

EnumsAreMergeable(enums):

- Let {inaccessibleValues} be the set of values that are declared as `@inaccessible` in {enums}.
- Let {requiredValues} be the set of values in {enums} that are not in {inaccessibleValues}.
- For each {enum} in {enums}
- Let {enumValues} be the set of all values of {enum} that are not in {inaccessibleValues}.
- {requiredValues} must be equal to {enumValues}

**Explanatory Text**

This rule ensures that enum types with the same name across different source schemas in a composite schema have identical sets of values.
Enums must be consistent across source schemas to avoid conflicts and ambiguities in the composite schema.

When an enum is defined with differing values, it can lead to confusion and errors in query execution.
For instance, a value valid in one schema might be passed to another where it's unrecognized, leading to unexpected behavior or failures.
This rule prevents such inconsistencies by enforcing that all instances of the same named enum across schemas have an exact match in their values.

In this example, both source schemas define `Enum1` with the same value `BAR`, satisfying the rule:

```graphql example
enum Enum1 {
BAR
}

enum Enum1 {
BAR
}
```

Here, the two definitions of `Enum1` have different values (`BAR` and `Baz`), violating the rule:

```graphql counter-example
enum Enum1 {
BAR
}

enum Enum1 {
Baz
}
```

Here, the two definitions of `Enum1` have shared values and additional values declared as `@inaccessible`, satisfying the rule:

```graphql example
enum Enum1 {
BAR
BAZ @inaccessible
}

enum Enum1 {
BAR
}
```

### Merge

### Post Merge Validation
Expand Down