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
Copy file name to clipboardExpand all lines: articles/api-management/graphql-policies.md
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,9 +138,6 @@ The `set-graphql-resolver` policy retrieves or sets data for a GraphQL field in
138
138
139
139
* This policy is invoked only when a matching GraphQL query is executed.
140
140
* The policy resolves data for a single field. To resolve data for multiple fields, configure multiple occurrences of this policy in a policy definition.
141
-
* The context for the HTTP request and HTTP response (if specified) differs from the context for the original gateway API request:
142
-
* The HTTP request context contains arguments that are passed in the GraphQL query as its body.
143
-
* The HTTP response context is the response from the independent HTTP call made by the resolver, not the context for the complete response for the gateway request.
@@ -203,6 +200,10 @@ This policy can be used in the following policy [sections](./api-management-howt
203
200
204
201
### GraphQL Context
205
202
203
+
* The context for the HTTP request and HTTP response (if specified) differs from the context for the original gateway API request:
204
+
*`context.ParentResult` is set to the parent object for the current resolver execution.
205
+
* The HTTP request context contains arguments that are passed in the GraphQL query as its body.
206
+
* The HTTP response context is the response from the independent HTTP call made by the resolver, not the context for the complete response for the gateway request.
206
207
The `context` variable that is passed through the request and response pipeline is augmented with the GraphQL context when used with `<set-graphql-resolver>` policies.
207
208
208
209
#### ParentResult
@@ -246,7 +247,7 @@ query {
246
247
}
247
248
```
248
249
249
-
If you set a resolver for `parent-type="Blog" field="comments"`, you will want to understand which blog ID to use. You can get this using `context.ParentResult.AsJObject()["id"].ToString()`. The policy for configuring this resolver would resemble:
250
+
If you set a resolver for `parent-type="Blog" field="comments"`, you will want to understand which blog ID to use. You can get the ID of the blog using `context.ParentResult.AsJObject()["id"].ToString()`. The policy for configuring this resolver would resemble:
### Resolver for a GraqhQL query that returns a list, using a liquid template
345
+
####Resolver for a GraqhQL query that returns a list, using a liquid template
345
346
346
347
The following example uses a liquid template, supported for use in the [set-body](api-management-transformation-policies.md#SetBody) policy, to return a list in the HTTP response to a query. It also renames the `username` field in the response from the REST API to `name` in the GraphQL response.
The following example resolves a mutation that inserts data by making a `POST` request to an HTTP data source. The policy expression in the `set-body` policy of the HTTP request modifies a `name` argument that is passed in the GraphQL query as its body. The body that is sent will look like the following JSON:
388
389
@@ -392,7 +393,7 @@ The following example resolves a mutation that inserts data by making a `POST` r
0 commit comments