From 78d52cf408494a9e16323bb5f1067cb3d365245e Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 1 Aug 2024 20:33:56 +0200 Subject: [PATCH 01/12] Adds Semantical Equivalence of Types Validation Rule --- spec/Section 4 -- Composition.md | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index 35d3b72..bf5b9b8 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -14,6 +14,67 @@ run in sequence to produce the composite execution schema. ### Pre Merge Validation +#### Semantical Equivalence of Types + +**Error Code** + +TYPE_KIND_NOT_MERGABLE + +**Formal Specification** + +- Let {typesByName} be the set of all types across all subgraphs involved in the + schema composition by their given type name. +- Given each pair of types {typeA} and {typeB} in {typesByName} + - {typeA} and {typeB} 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. Types that do not +share the same kind are considered non-mergeable. + +```graphql example +type User { + id: ID! + name: String! + displayName: String! + birthdate: String! +} + +type User { + id: ID! + name: String! + reviews: [Review!] +} +``` + +```graphql example +scalar DateTime + +scalar DateTime +``` + +```graphql counter-example +type User { + id: ID! + name: String! + displayName: String! + birthdate: String! +} + +scalar User +``` + +```graphql counter-example +enum UserKind { + A + B + C +} + +scalar UserKind +``` + ### Merge ### Post Merge Validation From f42d7a34412033d10acf4c398b2e3fdd03f0b5a8 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 1 Aug 2024 20:36:38 +0200 Subject: [PATCH 02/12] Format --- spec/Section 4 -- Composition.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index bf5b9b8..f36fb17 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -30,8 +30,8 @@ TYPE_KIND_NOT_MERGABLE **Explanatory Text** The GraphQL Composite Schemas specification considers types with the same name -across source schemas as semantically equivalent and mergeable. Types that do not -share the same kind are considered non-mergeable. +across source schemas as semantically equivalent and mergeable. Types that do +not share the same kind are considered non-mergeable. ```graphql example type User { From deb504464e22372690ebf8555f984513d31fdb84 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 1 Aug 2024 20:37:47 +0200 Subject: [PATCH 03/12] Spelling --- cspell.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/cspell.yml b/cspell.yml index 06d3a5b..9d7973d 100644 --- a/cspell.yml +++ b/cspell.yml @@ -31,3 +31,4 @@ words: ignoreWords: - Aremergeable - FXXXX + - TYPE_KIND_NOT_MERGABLE From 35521ffaf214e55c6a6e18743e46e44a19708c17 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 1 Aug 2024 20:38:59 +0200 Subject: [PATCH 04/12] Spelling --- spec/Section 4 -- Composition.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index f36fb17..d0af79e 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -18,7 +18,7 @@ run in sequence to produce the composite execution schema. **Error Code** -TYPE_KIND_NOT_MERGABLE +`TYPE_KIND_NOT_MERGABLE` **Formal Specification** From 96a1b611c8912ac9fd1604bd13082ab00369a112 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 15 Aug 2024 15:49:57 +0200 Subject: [PATCH 05/12] spelling --- spec/Section 4 -- Composition.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index d0af79e..d1b2f61 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -22,7 +22,7 @@ run in sequence to produce the composite execution schema. **Formal Specification** -- Let {typesByName} be the set of all types across all subgraphs involved in the +- Let {typesByName} be the set of all types across all source schemas involved in the schema composition by their given type name. - Given each pair of types {typeA} and {typeB} in {typesByName} - {typeA} and {typeB} must have the same kind From 0c79035d2b0b3824f6c1bca59153c8bf345a139d Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 15 Aug 2024 16:07:21 +0200 Subject: [PATCH 06/12] Update spec/Section 4 -- Composition.md Co-authored-by: Glen --- spec/Section 4 -- Composition.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index d1b2f61..25334ff 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -18,7 +18,7 @@ run in sequence to produce the composite execution schema. **Error Code** -`TYPE_KIND_NOT_MERGABLE` +`TYPE_KIND_NOT_MERGEABLE` **Formal Specification** From 995a997655c26d176d134b8bc407627979ca6a06 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 15 Aug 2024 16:07:26 +0200 Subject: [PATCH 07/12] Update cspell.yml Co-authored-by: Glen --- cspell.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/cspell.yml b/cspell.yml index 9d7973d..06d3a5b 100644 --- a/cspell.yml +++ b/cspell.yml @@ -31,4 +31,3 @@ words: ignoreWords: - Aremergeable - FXXXX - - TYPE_KIND_NOT_MERGABLE From ecf3873ce6d6a16f84ef1e4d09232fc94db0756d Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 15 Aug 2024 16:07:34 +0200 Subject: [PATCH 08/12] Update spec/Section 4 -- Composition.md Co-authored-by: Glen --- spec/Section 4 -- Composition.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index 25334ff..e7d869c 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -14,7 +14,7 @@ run in sequence to produce the composite execution schema. ### Pre Merge Validation -#### Semantical Equivalence of Types +#### Semantic Equivalence of Types **Error Code** From b868927ca970e93c39de78ef206a9dd6e590ce26 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 15 Aug 2024 16:08:11 +0200 Subject: [PATCH 09/12] algorithm --- spec/Section 4 -- Composition.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index e7d869c..839e897 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -22,10 +22,13 @@ run in sequence to produce the composite execution schema. **Formal Specification** -- Let {typesByName} be the set of all types across all source schemas involved in the - schema composition by their given type name. -- Given each pair of types {typeA} and {typeB} in {typesByName} - - {typeA} and {typeB} must have the same kind +- 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** From 075abce72c58b19c0e28ef12b0650a54b26660a7 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 15 Aug 2024 16:19:12 +0200 Subject: [PATCH 10/12] explained the examples more --- spec/Section 4 -- Composition.md | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index 839e897..bac6f25 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -25,7 +25,8 @@ run in sequence to produce the composite execution schema. - 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. + - 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. @@ -33,8 +34,11 @@ run in sequence to produce the composite execution schema. **Explanatory Text** The GraphQL Composite Schemas specification considers types with the same name -across source schemas as semantically equivalent and mergeable. Types that do -not share the same kind are considered non-mergeable. +across source schemas as semantically equivalent and mergeable. + +For the schema schema composition process to be able to merge types with the +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 { @@ -51,11 +55,8 @@ type User { } ``` -```graphql example -scalar DateTime - -scalar DateTime -``` +However, if the second type would be a scalar type, the types would not be +mergeable as they have different kinds. ```graphql counter-example type User { @@ -68,14 +69,12 @@ type User { scalar User ``` -```graphql counter-example -enum UserKind { - A - B - C -} +All types with the same name must have the same kind to be mergeable. -scalar UserKind +```graphql example +scalar User + +scalar User ``` ### Merge From 6782cd022cdc7278d6507ab46b75b8e9314ecb3f Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 15 Aug 2024 16:28:04 +0200 Subject: [PATCH 11/12] Update spec/Section 4 -- Composition.md Co-authored-by: Glen --- spec/Section 4 -- Composition.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index bac6f25..43c6183 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -36,7 +36,7 @@ run in sequence to produce the composite execution schema. 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 +For the schema composition process to be able to merge types with the 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. From bba977a0560ef20b592ca59ea4c625bc9a4b9701 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 15 Aug 2024 16:28:18 +0200 Subject: [PATCH 12/12] Update spec/Section 4 -- Composition.md Co-authored-by: Glen --- spec/Section 4 -- Composition.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index 43c6183..2d90a0c 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -55,7 +55,7 @@ type User { } ``` -However, if the second type would be a scalar type, the types would not be +However, if the second type were a scalar type, the types would not be mergeable as they have different kinds. ```graphql counter-example