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 Semantical Equivalence of Types Validation Rule #37

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

### Pre Merge Validation

#### Semantic Equivalence of Types

**Error Code**

`TYPE_KIND_NOT_MERGEABLE`

**Formal Specification**

- Let {typesByName} be an empty unordered map of sets.
- For each named type {type} across all source schemas:
- Let {name} be the name of {type}.
- Let {set} be the set in {typesByName} for {name}; if no such set exists,
create it as an empty set.
- Add {type} to {set}.
- For each {typesByName} as {name} and {types}:
- Each pair of types in {types} must have the same kind.

**Explanatory Text**

The GraphQL Composite Schemas specification considers types with the same name
across source schemas as semantically equivalent and mergeable.

For the schema schema composition process to be able to merge types with the
michaelstaib marked this conversation as resolved.
Show resolved Hide resolved
same name, the types must have the same kind. In this example we have two types
called `User` which are both object types and are mergeable.

```graphql example
type User {
id: ID!
name: String!
displayName: String!
birthdate: String!
}

type User {
id: ID!
name: String!
reviews: [Review!]
}
```

However, if the second type would be a scalar type, the types would not be
michaelstaib marked this conversation as resolved.
Show resolved Hide resolved
mergeable as they have different kinds.

```graphql counter-example
type User {
id: ID!
name: String!
displayName: String!
birthdate: String!
}

scalar User
```

All types with the same name must have the same kind to be mergeable.

```graphql example
scalar User

scalar User
```

### Merge

### Post Merge Validation
Expand Down
Loading