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
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -343,7 +343,7 @@ type User {
343
343
344
344
### Resolver for a GraqhQL query that returns a list, using a liquid template
345
345
346
-
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.
346
+
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.
347
347
348
348
#### Example schema
349
349
@@ -372,7 +372,7 @@ type User {
372
372
[
373
373
{% JSONArrayFor elem in body %}
374
374
{
375
-
"name": "{{elem.title}}"
375
+
"name": "{{elem.username}}"
376
376
}
377
377
{% endJSONArrayFor %}
378
378
]
@@ -384,7 +384,13 @@ type User {
384
384
385
385
### Resolver for GraphQL mutation
386
386
387
-
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.
387
+
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
+
```json
390
+
{
391
+
"name": "the-provided-name"
392
+
}
393
+
```
388
394
389
395
#### Example schema
390
396
@@ -415,9 +421,9 @@ type User {
415
421
<value>application/json</value>
416
422
</set-header>
417
423
<set-body>@{
418
-
var body = context.Request.Body.As<JObject>(true);
424
+
var args = context.Request.Body.As<JObject>(true)["arguments"];
0 commit comments