From 7606c0d78fb7f89ea8d5ceaf35f9a04281a13053 Mon Sep 17 00:00:00 2001 From: PascalSenn Date: Sun, 4 Aug 2024 20:49:17 +0200 Subject: [PATCH 1/6] Adds empty merged input object type to composition --- spec/Section 4 -- Composition.md | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index 35d3b72..1b820a3 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -18,4 +18,49 @@ run in sequence to produce the composite execution schema. ### Post Merge Validation +#### Empty Merged Input Object Type + +**Error Code** + +INPUT_OBJECT_TYPE_EMPTY + +**Formal Specification** + +- Let {inputs} be the set of all input object in the merged schema +- For each {input} in {inputs}: + - {IsInputObjectTypeEmpty(input)} must be false + +IsInputObjectTypeEmpty(input): + +- Let {fields} be a set of all input fields of {input} +- For each {field} in {fields}: + - If {field} is not flagged as `@inaccessible`: + - return false +- return true + +**Explanatory Text** + +When an input object type is defined in multiple source schemas, fields flagged as `@inaccessible` are not included in the merged input object type. +If this process results in an input object type with no fields, the input object type is considered empty and invalid. + +In the following example, the merged input object type `Input1` is valid. + +```graphql +input Input1 { + field1: String @inaccessible + field2: Int +} +``` + +This counter-example shows an invalid merged input object type. +The `Input1` type is defined in two source schemas, but both `field1` and `field2` are flagged as +`@inaccessible` in at least on of the schemas: + +```graphql counter-example +input Input1 { + field1: String @inaccessible + field2: Int @inaccessible +} +``` + ## Validate Satisfiability From 813505ff924dd98efc9ed24d9ea0dfd230e07935 Mon Sep 17 00:00:00 2001 From: PascalSenn Date: Wed, 7 Aug 2024 19:38:22 +0200 Subject: [PATCH 2/6] Update 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 1b820a3..17d5922 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -26,7 +26,7 @@ INPUT_OBJECT_TYPE_EMPTY **Formal Specification** -- Let {inputs} be the set of all input object in the merged schema +- Let {inputs} be the set of all input objects in the merged schema - For each {input} in {inputs}: - {IsInputObjectTypeEmpty(input)} must be false From 7ecfafc7be225ca027ce2c723da2a03da0bf9c76 Mon Sep 17 00:00:00 2001 From: PascalSenn Date: Wed, 7 Aug 2024 19:38:26 +0200 Subject: [PATCH 3/6] Update 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 17d5922..c58b83e 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -54,7 +54,7 @@ input Input1 { This counter-example shows an invalid merged input object type. The `Input1` type is defined in two source schemas, but both `field1` and `field2` are flagged as -`@inaccessible` in at least on of the schemas: +`@inaccessible` in at least one of the schemas: ```graphql counter-example input Input1 { From 9ad125004bc5c1fd302d50298120d19881843dc8 Mon Sep 17 00:00:00 2001 From: PascalSenn Date: Thu, 7 Nov 2024 15:31:53 +0100 Subject: [PATCH 4/6] Cleanup rule --- spec/Section 4 -- Composition.md | 45 -------------------------------- 1 file changed, 45 deletions(-) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index c58b83e..35d3b72 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -18,49 +18,4 @@ run in sequence to produce the composite execution schema. ### Post Merge Validation -#### Empty Merged Input Object Type - -**Error Code** - -INPUT_OBJECT_TYPE_EMPTY - -**Formal Specification** - -- Let {inputs} be the set of all input objects in the merged schema -- For each {input} in {inputs}: - - {IsInputObjectTypeEmpty(input)} must be false - -IsInputObjectTypeEmpty(input): - -- Let {fields} be a set of all input fields of {input} -- For each {field} in {fields}: - - If {field} is not flagged as `@inaccessible`: - - return false -- return true - -**Explanatory Text** - -When an input object type is defined in multiple source schemas, fields flagged as `@inaccessible` are not included in the merged input object type. -If this process results in an input object type with no fields, the input object type is considered empty and invalid. - -In the following example, the merged input object type `Input1` is valid. - -```graphql -input Input1 { - field1: String @inaccessible - field2: Int -} -``` - -This counter-example shows an invalid merged input object type. -The `Input1` type is defined in two source schemas, but both `field1` and `field2` are flagged as -`@inaccessible` in at least one of the schemas: - -```graphql counter-example -input Input1 { - field1: String @inaccessible - field2: Int @inaccessible -} -``` - ## Validate Satisfiability From 169658c00ba47af60f812ba56975ef0da8d55977 Mon Sep 17 00:00:00 2001 From: PascalSenn Date: Thu, 7 Nov 2024 16:41:56 +0100 Subject: [PATCH 5/6] Cleanup rule --- spec/Section 4 -- Composition.md | 92 ++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index 1ea1a52..da5c815 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -14,6 +14,98 @@ run in sequence to produce the composite execution schema. ### Pre Merge Validation +#### Empty Merged Input Object Type + +**Error Code** + +`EMPTY_MERGED_INPUT_OBJECT_TYPE` + +**Severity** ERROR + +**Formal Specification** + +- Let {inputTypes} be the set of all input object types across all source + schemas +- For each {inputType} in {inputTypes}: + - {IsInputObjectTypeEmpty(inputType)} must be false. + +**IsInputObjectTypeEmpty(inputType):** + +1. If {inputType} has the `@inaccessible` directive + - return false +2. Let {fields} be a set of all fields in {inputType} +3. For each {field} in {fields}: + - If {IsExposed(field)} is true + - return false +4. return true + +**Explanatory Text** + +For input object types defined across multiple source schemas, the merged input +object type is the intersection of all fields defined in these source schemas. +Any field marked with the `@inaccessible` directive in any source schema is +hidden and not included in the merged input object type. An input object type +with no fields, after considering `@inaccessible` annotations, is considered +empty and invalid. + +In the following example, the merged input object type `InputObjectType1` is +valid. + +```graphql +input InputObjectType1 { + inputField1: String +} + +input InputObjectType1 { + inputField1: String +} +``` + +If the `@inaccessible` directive is applied to an input object type itself, the +entire merged input object type is excluded from the composite execution schema, +and it is not required to contain any fields. + +```graphql +input InputObjectType1 @inaccessible { + inputField1: String + inputField2: Int +} + +input InputObjectType1 { + inputField3: Boolean +} +``` + +This counter-example demonstrates an invalid merged input object type. In this +case, `InputObjectType1` 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 input object type: + +```graphql counter-example +input InputObjectType1 { + inputField1: String @inaccessible + inputField2: Boolean +} + +input InputObjectType1 { + inputField1: String + inputField2: Boolean @inaccessible +} +``` + +Here is another counter-example where the merged input object type is empty +because no fields intersect between the two source schemas: + +```graphql counter-example +input InputObjectType1 { + inputField2: Boolean +} + +input InputObjectType1 { + inputField1: String +} +``` + #### Output Field Types Mergeable **Error Code** From ba12c58f33146c2fc2fc9d0cd6b658e84e4e412b Mon Sep 17 00:00:00 2001 From: PascalSenn Date: Thu, 7 Nov 2024 16:43:04 +0100 Subject: [PATCH 6/6] Cleanup rule --- spec/Section 4 -- Composition.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/Section 4 -- Composition.md b/spec/Section 4 -- Composition.md index da5c815..8bd117f 100644 --- a/spec/Section 4 -- Composition.md +++ b/spec/Section 4 -- Composition.md @@ -20,7 +20,9 @@ run in sequence to produce the composite execution schema. `EMPTY_MERGED_INPUT_OBJECT_TYPE` -**Severity** ERROR +**Severity** + +ERROR **Formal Specification**