From fcc8f8a6048d398c8106fac426508bce17038f89 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 15 Aug 2024 15:43:37 +0200 Subject: [PATCH 1/3] Adds Empty Object Type Validation Rule --- spec/Section 4 -- Composition.md | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index 35d3b72..9c503cc 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -18,4 +18,66 @@ run in sequence to produce the composite execution schema. ### Post Merge Validation +#### Empty Merged Object Type + +**Error Code** + +`Empty_Merged_Object_Type` + +**Formal Specification** + +- Let {types} be the set of all object types across all source schemas +- For each {type} in {types}: + - {IsObjectTypeEmpty(type)} must be false. + +IsObjectTypeEmpty(type): + +- Let {fields} be a set of all fields of all types with coordinate and kind + {type} across all source schemas +- For each {field} in {fields}: + - If {IsExposed(field)} is true + - return false +- return true + +**Explanatory Text** + +For object types defined across multiple source schemas, the merged object type is +the superset of all fields defined in these source schemas. However, any field marked +with `@inaccessible` in any source schema is hidden and not included in the merged object +type. An object type with no fields, after considering `@inaccessible` annotations, is +considered empty and invalid. + +In the following example, the merged object type `ObjectType1` is valid. It +includes all fields from both source schemas, with `field2` being hidden due to the +`@inaccessible` directive in one of the source schemas: + +```graphql +type ObjectType1 { + field1: String + field2: Int @inaccessible +} + +type ObjectType1 { + field2: Int + field3: Boolean +} +``` + +This counter-example demonstrates an invalid merged object type. In this case, +`ObjectType1` is defined in two source schemas, but all fields are marked as +`@inaccessible` in at least one of the source schemas, resulting in an empty merged +object type: + +```graphql counter-example +type ObjectType1 { + field1: String @inaccessible + field2: Boolean +} + +type ObjectType1 { + field1: String + field2: Boolean @inaccessible +} +``` + ## Validate Satisfiability From eb1433c74276f8546090fe773593fcd8d5b4c495 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 15 Aug 2024 15:44:27 +0200 Subject: [PATCH 2/3] Formatted --- spec/Section 4 -- Composition.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index 9c503cc..431d837 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -41,15 +41,15 @@ IsObjectTypeEmpty(type): **Explanatory Text** -For object types defined across multiple source schemas, the merged object type is -the superset of all fields defined in these source schemas. However, any field marked -with `@inaccessible` in any source schema is hidden and not included in the merged object -type. An object type with no fields, after considering `@inaccessible` annotations, is -considered empty and invalid. +For object types defined across multiple source schemas, the merged object type +is the superset of all fields defined in these source schemas. However, any +field marked with `@inaccessible` in any source schema is hidden and not +included in the merged object type. An object type with no fields, after +considering `@inaccessible` annotations, is considered empty and invalid. In the following example, the merged object type `ObjectType1` is valid. It -includes all fields from both source schemas, with `field2` being hidden due to the -`@inaccessible` directive in one of the source schemas: +includes all fields from both source schemas, with `field2` being hidden due to +the `@inaccessible` directive in one of the source schemas: ```graphql type ObjectType1 { @@ -65,8 +65,8 @@ type ObjectType1 { This counter-example demonstrates an invalid merged object type. In this case, `ObjectType1` is defined in two source schemas, but all fields are marked as -`@inaccessible` in at least one of the source schemas, resulting in an empty merged -object type: +`@inaccessible` in at least one of the source schemas, resulting in an empty +merged object type: ```graphql counter-example type ObjectType1 { From 8dd5fbe0124f6c68aaeb40096ae49b1e972a400f Mon Sep 17 00:00:00 2001 From: PascalSenn Date: Thu, 7 Nov 2024 13:06:45 +0100 Subject: [PATCH 3/3] pse/fixed empty object type (#58) --- spec/Section 4 -- Composition.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index 431d837..6b6232c 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -22,7 +22,9 @@ run in sequence to produce the composite execution schema. **Error Code** -`Empty_Merged_Object_Type` +`EMPTY_MERGED_OBJECT_TYPE` + +**Severity** ERROR **Formal Specification** @@ -32,8 +34,9 @@ run in sequence to produce the composite execution schema. IsObjectTypeEmpty(type): -- Let {fields} be a set of all fields of all types with coordinate and kind - {type} across all source schemas +- If {type} has `@inaccessible` directive +- return false +- Let {fields} be a set of all fields in {type} - For each {field} in {fields}: - If {IsExposed(field)} is true - return false @@ -63,6 +66,21 @@ type ObjectType1 { } ``` +If the `@inaccessible` directive is applied to an object type itself, the entire +merged object type is excluded from the composite execution schema, and it is +not required to contain any fields. + +```graphql +type ObjectType1 @inaccessible { + field1: String + field2: Int +} + +type ObjectType1 { + field3: Boolean +} +``` + This counter-example demonstrates an invalid merged object type. In this case, `ObjectType1` is defined in two source schemas, but all fields are marked as `@inaccessible` in at least one of the source schemas, resulting in an empty