You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**`visibility_profiles:`**, an array of [visibility profiles](./visibility.md) that the supergraph responds to.
64
60
65
-
-**`description_merger:`**, a [value merger function](#value-merger-functions) for merging element description strings from across locations.
66
-
67
-
-**`deprecation_merger:`**, a [value merger function](#value-merger-functions) for merging element deprecation strings from across locations.
68
-
69
-
-**`default_value_merger:`**, a [value merger function](#value-merger-functions) for merging argument default values from across locations.
70
-
71
-
-**`directive_kwarg_merger:`**, a [value merger function](#value-merger-functions) for merging directive keyword arguments from across locations.
72
-
73
61
-**`root_entrypoints:`**, a hash of root field names mapped to their entrypoint locations, see [overlapping root fields](#overlapping-root-fields) below.
74
62
75
-
####Value merger functions
63
+
### Value mergers
76
64
77
-
Static data values such as element descriptions and directive arguments must also merge across locations. By default, the first non-null value encountered for a given element attribute is used. A value merger function may customize this process by selecting a different value or computing a new one:
65
+
Static data values such as element descriptions and directive arguments must also merge across locations. By default, the first non-null value encountered for a given element property is used. Value merger methods can be customized by defining them on your own `Client` class:
# return a merged element description string from across locations...
71
+
values_by_location.each_value.join("\n")
72
+
end
73
+
74
+
defmerge_deprecations(values_by_location, info)
75
+
# return a merged element deprecation string from across locations...
76
+
end
77
+
78
+
defmerge_default_values(values_by_location, info)
79
+
# return a merged argument default value from across locations...
80
+
end
81
+
82
+
defmerge_kwargs(values_by_location, info)
83
+
# return a merged directive keyword argument from across locations...
84
+
end
85
+
end
86
+
87
+
client =MyClient.new(locations: ...)
90
88
```
91
89
92
-
A merger function receives`values_by_location` and `info` arguments; these provide possible values keyed by location and info about where in the schema these values were encountered:
90
+
All merge functions receive`values_by_location` and `info` arguments; these provide possible values keyed by location and info about where in the schema these values were encountered. For example:
93
91
94
92
```ruby
95
93
values_by_location = {
96
-
"users" => "A fabulous data type.",
97
-
"products" => "An excellent data type.",
94
+
"users" => "A fabulous data type description.",
95
+
"products" => "An excellent data type description.",
Copy file name to clipboardExpand all lines: docs/error_handling.md
+13-5Lines changed: 13 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,20 +4,28 @@ Failed stitching requests can be tricky to debug because it's not always obvious
4
4
5
5
### Supergraph errors
6
6
7
-
When exceptions happen while executing requests within the stitching layer, they will be rescued by the stitching client and trigger an `on_error` hook. You should add your stack's error reporting here and return a formatted error message to appear in [GraphQL errors](https://spec.graphql.org/June2018/#sec-Errors) for the request.
7
+
When exceptions happen while executing requests within the stitching layer, they will be rescued by the stitching client and trigger an `on_error` hook. You can add your stack's error reporting here:
# return a formatted message for the public response
16
-
"Whoops, please contact support abount request '#{request.context[:request_id]}'"
17
+
To modify the format of returned error messages that appear in [GraphQL errors](https://spec.graphql.org/June2018/#sec-Errors), extend `Client` and define your own `build_graphql_error` method:
18
+
19
+
```ruby
20
+
classMyClient < GraphQL::Stitching::Client
21
+
defbuild_graphql_error(request, err)
22
+
graphql_error =super(request, err)
23
+
graphql_error["message"] <<" Contact support about Request ID #{request.context[:request_id]}"
0 commit comments