Skip to content

Commit 45de368

Browse files
Merge pull request #269581 from dlepow/43
[APIM] Policy updates for release
2 parents d22c5ec + 185912b commit 45de368

File tree

2 files changed

+63
-5
lines changed

2 files changed

+63
-5
lines changed

articles/api-management/http-data-source-policy.md

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: dlepow
66

77
ms.service: api-management
88
ms.topic: article
9-
ms.date: 03/07/2023
9+
ms.date: 03/19/2024
1010
ms.author: danlep
1111
---
1212

@@ -95,6 +95,7 @@ The `http-data-source` resolver policy configures the HTTP request and optionall
9595

9696
* To configure and manage a resolver with this policy, see [Configure a GraphQL resolver](configure-graphql-resolver.md).
9797
* This policy is invoked only when resolving a single field in a matching GraphQL operation type in the schema.
98+
* This policy supports GraphQL [union types](https://spec.graphql.org/October2021/#sec-Unions).
9899

99100
## Examples
100101

@@ -167,7 +168,7 @@ type User {
167168

168169
### Resolver for GraphQL mutation
169170

170-
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:
171+
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:
171172

172173
``` json
173174
{
@@ -198,7 +199,7 @@ type User {
198199
<http-data-source>
199200
<http-request>
200201
<set-method>POST</set-method>
201-
<set-url> https://data.contoso.com/user/create </set-url>
202+
<set-url>https://data.contoso.com/user/create </set-url>
202203
<set-header name="Content-Type" exists-action="override">
203204
<value>application/json</value>
204205
</set-header>
@@ -212,6 +213,63 @@ type User {
212213
</http-data-source>
213214
```
214215

216+
### Resolver for GraphQL union type
217+
218+
The following example resolves the `orderById` query by making an HTTP `GET` call to a backend data source and returns a JSON object that includes the customer ID and type. The customer type is a union of `RegisteredCustomer` and `GuestCustomer` types.
219+
220+
#### Example schema
221+
222+
```graphql
223+
type Query {
224+
orderById(orderId: Int): Order
225+
}
226+
227+
type Order {
228+
customerId: Int!
229+
orderId: Int!
230+
customer: Customer
231+
}
232+
233+
enum AccountType {
234+
Registered
235+
Guest
236+
}
237+
238+
union Customer = RegisteredCustomer | GuestCustomer
239+
240+
type RegisteredCustomer {
241+
accountType: AccountType!
242+
customerId: Int!
243+
customerGuid: String!
244+
firstName: String!
245+
lastName: String!
246+
isActive: Boolean!
247+
}
248+
249+
type GuestCustomer {
250+
accountType: AccountType!
251+
firstName: String!
252+
lastName: String!
253+
}
254+
```
255+
256+
#### Example policy
257+
258+
For this example, we mock the customer results from an external source, and hard code the fetched results in the `set-body` policy. The `__typename` field is used to determine the type of the customer.
259+
260+
```xml
261+
<http-data-source>
262+
<http-request>
263+
<set-method>GET</set-method>
264+
<set-url>https://data.contoso.com/orders/</set-url>
265+
</http-request>
266+
<http-response>
267+
<set-body>{"customerId": 12345, "accountType": "Registered", "__typename": "RegisteredCustomer" }
268+
</set-body>
269+
</http-response>
270+
</http-data-source>
271+
```
272+
215273
## Related policies
216274

217275
* [GraphQL resolver policies](api-management-policies.md#graphql-resolver-policies)

articles/api-management/validate-azure-ad-token-policy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ The `validate-azure-ad-token` policy enforces the existence and validity of a JS
6969

7070
| Element | Description | Required |
7171
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
72-
| audiences | Contains a list of acceptable audience claims that can be present on the token. If multiple audience values are present, then each value is tried until either all are exhausted (in which case validation fails) or until one succeeds. At least one audience must be specified. Policy expressions are allowed. | No |
72+
| audiences | Contains a list of acceptable audience claims that can be present on the token. If multiple `audience` values are present, then each value is tried until either all are exhausted (in which case validation fails) or until one succeeds. Policy expressions are allowed. | No |
7373
| backend-application-ids | Contains a list of acceptable backend application IDs. This is only required in advanced cases for the configuration of options and can generally be removed. Policy expressions aren't allowed. | No |
74-
| client-application-ids | Contains a list of acceptable client application IDs. If multiple application-id elements are present, then each value is tried until either all are exhausted (in which case validation fails) or until one succeeds. At least one application-id must be specified. Policy expressions aren't allowed. | Yes |
74+
| client-application-ids | Contains a list of acceptable client application IDs. If multiple `application-id` elements are present, then each value is tried until either all are exhausted (in which case validation fails) or until one succeeds. If a client application ID isn't provided, one or more `audience` claims should be specified. Policy expressions aren't allowed. | No |
7575
| required-claims | Contains a list of `claim` elements for claim values expected to be present on the token for it to be considered valid. When the `match` attribute is set to `all`, every claim value in the policy must be present in the token for validation to succeed. When the `match` attribute is set to `any`, at least one claim must be present in the token for validation to succeed. Policy expressions are allowed. | No |
7676

7777
### claim attributes

0 commit comments

Comments
 (0)