From e4562c418c419deb51ab24d23f35b388689740e4 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 7 Nov 2024 16:49:11 +0100 Subject: [PATCH 1/7] Adds @inaccessible --- spec/Section 2 -- Source Schema.md | 80 ++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/spec/Section 2 -- Source Schema.md b/spec/Section 2 -- Source Schema.md index 5bbc683..632611b 100644 --- a/spec/Section 2 -- Source Schema.md +++ b/spec/Section 2 -- Source Schema.md @@ -211,6 +211,86 @@ resolve entities and which source schemas merely contribute data to entities. Further, using `@internal` allows hiding "technical" lookup fields that are not meant for the client-facing composite schema. +### @inaccessible + +```graphql +directive @inaccessible on OBJECT | FIELD_DEFINITION +``` + +The `@inaccessible` directive is used to prevent specific objects or fields from +being accessible through the composite schema, even if they are accessible in +the underlying source schemas. + +This directive is particularly useful for restricting access to fields or +objects that are either irrelevant to the client-facing API or sensitive in +nature, such as internal identifiers or fields intended only for backend use. + +```graphql example +type Product @key(fields: "id") @key(fields: "sku") { + id: ID! + sku: String! @inaccessible + internalNote: String +} + +type Query { + productById(id: ID!): Product + productBySku(sku: String!): Product @inaccessible +} +``` + +The above example declares the key field `sku` to be inaccessible through from +the composite schema. However, type system members marked as inaccessible can +still be used within the composite execution schema to fulfill requirements or +lookups. + +In contrast to the `@internal` directive the `@inaccessible` directive hides a +type member from composite schema even if other source schemas on the same type +system member have no `@inaccessible` directive. + +```graphql example +# Source Schema A +type Product @key(fields: "id") @key(fields: "sku") { + id: ID! + sku: String! @inaccessible + internalNote: String +} + +# Source Schema B +type Product @key(fields: "sku") { + sku: String! + price: Float! +} + +# Composite Schema + +type Product { + id: ID! + internalNote: String + price: Float! +} +``` + +The above example removes the field `internalProductById` and the type `Product` +from the the composite schema. However, type system members marked as +inaccessible can still be used within the composite execution schema to fulfill +requirements. + +Unlike @internal, which restricts lookup fields to backend use, @inaccessible +completely excludes the marked elements from the composite schema. + +```graphql example +type Product @inaccessible { + id: ID! + sku: String! + internalNote: String +} + +type Query { + publicProductById(id: ID!): Product + internalProductById(id: ID!): Product @inaccessible +} +``` + ### @is ```graphql From 5042524ec7af06aba2d66c3fedb279aad13ce9ca Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 14 Nov 2024 12:23:06 +0200 Subject: [PATCH 2/7] Update spec/Section 2 -- Source Schema.md Co-authored-by: Glen --- spec/Section 2 -- Source Schema.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/Section 2 -- Source Schema.md b/spec/Section 2 -- Source Schema.md index 632611b..603e508 100644 --- a/spec/Section 2 -- Source Schema.md +++ b/spec/Section 2 -- Source Schema.md @@ -238,7 +238,7 @@ type Query { } ``` -The above example declares the key field `sku` to be inaccessible through from +The above example declares the key field `sku` to be inaccessible from the composite schema. However, type system members marked as inaccessible can still be used within the composite execution schema to fulfill requirements or lookups. From 8eb18ca9f25c5e71161689ac2bf85119655feb6d Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 14 Nov 2024 12:23:12 +0200 Subject: [PATCH 3/7] Update spec/Section 2 -- Source Schema.md Co-authored-by: Glen --- spec/Section 2 -- Source Schema.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/Section 2 -- Source Schema.md b/spec/Section 2 -- Source Schema.md index 603e508..7969efb 100644 --- a/spec/Section 2 -- Source Schema.md +++ b/spec/Section 2 -- Source Schema.md @@ -244,7 +244,7 @@ still be used within the composite execution schema to fulfill requirements or lookups. In contrast to the `@internal` directive the `@inaccessible` directive hides a -type member from composite schema even if other source schemas on the same type +type member from the composite schema even if other source schemas on the same type system member have no `@inaccessible` directive. ```graphql example From 2ef6255290cbde0938daa7e700fefad69d5a4ad4 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 14 Nov 2024 12:23:18 +0200 Subject: [PATCH 4/7] Update spec/Section 2 -- Source Schema.md Co-authored-by: Glen --- spec/Section 2 -- Source Schema.md | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/Section 2 -- Source Schema.md b/spec/Section 2 -- Source Schema.md index 7969efb..9a36bc3 100644 --- a/spec/Section 2 -- Source Schema.md +++ b/spec/Section 2 -- Source Schema.md @@ -262,7 +262,6 @@ type Product @key(fields: "sku") { } # Composite Schema - type Product { id: ID! internalNote: String From 401b5167d136ad46e90c452bf9875abcb0a42200 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 14 Nov 2024 12:23:24 +0200 Subject: [PATCH 5/7] Update spec/Section 2 -- Source Schema.md Co-authored-by: Glen --- spec/Section 2 -- Source Schema.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/Section 2 -- Source Schema.md b/spec/Section 2 -- Source Schema.md index 9a36bc3..f494f76 100644 --- a/spec/Section 2 -- Source Schema.md +++ b/spec/Section 2 -- Source Schema.md @@ -269,7 +269,7 @@ type Product { } ``` -The above example removes the field `internalProductById` and the type `Product` +The example below removes the field `internalProductById` and the type `Product` from the the composite schema. However, type system members marked as inaccessible can still be used within the composite execution schema to fulfill requirements. From 1690132170a5bb8ac55ba5af9c8539a870c687de Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 14 Nov 2024 12:23:31 +0200 Subject: [PATCH 6/7] Update spec/Section 2 -- Source Schema.md Co-authored-by: Glen --- spec/Section 2 -- Source Schema.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/Section 2 -- Source Schema.md b/spec/Section 2 -- Source Schema.md index f494f76..d48e84c 100644 --- a/spec/Section 2 -- Source Schema.md +++ b/spec/Section 2 -- Source Schema.md @@ -271,7 +271,7 @@ type Product { The example below removes the field `internalProductById` and the type `Product` from the the composite schema. However, type system members marked as -inaccessible can still be used within the composite execution schema to fulfill +inaccessible can still be used within the composite execution schema to fulfil requirements. Unlike @internal, which restricts lookup fields to backend use, @inaccessible From 4cd2af5b8001cafa2bf9706ffa3239623f803e06 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Thu, 14 Nov 2024 12:23:35 +0200 Subject: [PATCH 7/7] Update spec/Section 2 -- Source Schema.md Co-authored-by: Glen --- spec/Section 2 -- Source Schema.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/Section 2 -- Source Schema.md b/spec/Section 2 -- Source Schema.md index d48e84c..d80ec11 100644 --- a/spec/Section 2 -- Source Schema.md +++ b/spec/Section 2 -- Source Schema.md @@ -240,7 +240,7 @@ type Query { The above example declares the key field `sku` to be inaccessible from the composite schema. However, type system members marked as inaccessible can -still be used within the composite execution schema to fulfill requirements or +still be used within the composite execution schema to fulfil requirements or lookups. In contrast to the `@internal` directive the `@inaccessible` directive hides a