Skip to content

Commit 223984e

Browse files
committed
Updates for danlep
1 parent 4e405e6 commit 223984e

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

articles/api-management/graphql-policies.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ The `set-graphql-resolver` policy retrieves or sets data for a GraphQL field in
138138

139139
* This policy is invoked only when a matching GraphQL query is executed.
140140
* 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.
144141

145142
[!INCLUDE [api-management-policy-generic-alert](../../includes/api-management-policy-generic-alert.md)]
146143

@@ -203,6 +200,10 @@ This policy can be used in the following policy [sections](./api-management-howt
203200

204201
### GraphQL Context
205202

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.
206207
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.
207208

208209
#### ParentResult
@@ -246,7 +247,7 @@ query {
246247
}
247248
```
248249

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:
250251

251252
``` xml
252253
<set-graphql-resolver parent-type="Blog" field="comments">
@@ -262,7 +263,7 @@ If you set a resolver for `parent-type="Blog" field="comments"`, you will want t
262263
</set-graphql-resolver>
263264
```
264265

265-
### Arguments
266+
#### Arguments
266267

267268
The arguments for a parameterized GraphQL query are added to the body of the request. For example, consider the following two queries:
268269

@@ -311,11 +312,11 @@ When the resolver is executed, the `arguments` property is added to the body. Y
311312

312313
### More examples
313314

314-
### Resolver for GraphQL query
315+
#### Resolver for GraphQL query
315316

316317
The following example resolves a query by making an HTTP `GET` call to a backend data source.
317318

318-
#### Example schema
319+
##### Example schema
319320

320321
```
321322
type Query {
@@ -328,7 +329,7 @@ type User {
328329
}
329330
```
330331

331-
#### Example policy
332+
##### Example policy
332333

333334
```xml
334335
<set-graphql-resolver parent-type="Query" field="users">
@@ -341,11 +342,11 @@ type User {
341342
</set-graphql-resolver>
342343
```
343344

344-
### 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
345346

346347
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.
347348

348-
#### Example schema
349+
##### Example schema
349350

350351
```
351352
type Query {
@@ -358,7 +359,7 @@ type User {
358359
}
359360
```
360361

361-
#### Example policy
362+
##### Example policy
362363

363364
```xml
364365
<set-graphql-resolver parent-type="Query" field="users">
@@ -382,7 +383,7 @@ type User {
382383
</set-graphql-resolver>
383384
```
384385

385-
### Resolver for GraphQL mutation
386+
#### Resolver for GraphQL mutation
386387

387388
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:
388389

@@ -392,7 +393,7 @@ The following example resolves a mutation that inserts data by making a `POST` r
392393
}
393394
```
394395

395-
#### Example schema
396+
##### Example schema
396397

397398
```
398399
type Query {
@@ -409,7 +410,7 @@ type User {
409410
}
410411
```
411412

412-
#### Example policy
413+
##### Example policy
413414

414415
```xml
415416
<set-graphql-resolver parent-type="Mutation" field="makeUser">

0 commit comments

Comments
 (0)