Skip to content

Commit 652ea84

Browse files
authored
document disabling subgraph validations. (#184)
1 parent 2798005 commit 652ea84

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This Ruby implementation is designed as a generic library to join basic spec-com
2121

2222
## Documentation
2323

24-
1. [Introduction](./docs/introduction.md)
24+
1. [Introduction](./docs/README.md)
2525
1. [Composing a supergraph](./docs/composing_a_supergraph.md)
2626
1. [Merged types](./docs/merged_types.md)
2727
1. [Executables & file uploads](./docs/executables.md)
File renamed without changes.

docs/performance.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,34 @@ query($id: ID!) {
5757
# variables: { "id" => "1" }
5858
```
5959

60+
### Subgraph validations
61+
62+
Requests are validated by the supergraph, and should always divide into valid subgraph documents. Therefore, you can skip redundant subgraph validations for requests sent by the supergraph, ex:
63+
64+
```ruby
65+
exe = GraphQL::Stitching::HttpExecutable.new(
66+
url: "http://localhost:3001",
67+
headers: {
68+
"Authorization" => "...",
69+
"X-Supergraph-Secret" => "<shared-secret>",
70+
},
71+
)
72+
```
73+
74+
A shared secret allows a subgraph location to trust the supergraph origin, at which time it can disable validations:
75+
76+
```ruby
77+
def query
78+
sg_header = request.headers["X-Supergraph-Secret"]
79+
MySchema.execute(
80+
query: params[:query],
81+
variables: params[:variables],
82+
operation_name: params[:operationName],
83+
validate: sg_header.nil? || sg_header != Rails.env.credentials.supergraph,
84+
)
85+
end
86+
```
87+
6088
### Digests
6189

6290
All computed digests use SHA2 hashing by default. You can swap in [a faster algorithm](https://github.com/Shopify/blake3-rb) and/or add base state by reconfiguring `Stitching.digest`:

0 commit comments

Comments
 (0)