Skip to content

Commit 042d852

Browse files
Merge pull request #273321 from dlepow/gqlu
[APIM] GraphQL union and interface types
2 parents 6591e3b + 0984efe commit 042d852

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

articles/api-management/configure-graphql-resolver.md

Lines changed: 2 additions & 1 deletion
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: 06/08/2023
9+
ms.date: 05/02/2024
1010
ms.author: danlep
1111
---
1212

@@ -29,6 +29,7 @@ Currently, API Management supports resolvers that can access the following data
2929
* Each resolver resolves data for a single field. To resolve data for multiple fields, configure a separate resolver for each.
3030
* Resolver-scoped policies are evaluated *after* any `inbound` and `backend` policies in the policy execution pipeline. They don't inherit policies from other scopes. For more information, see [Policies in API Management](api-management-howto-policies.md).
3131
* You can configure API-scoped policies for a GraphQL API, independent of the resolver-scoped policies. For example, add a [validate-graphql-request](validate-graphql-request-policy.md) policy to the `inbound` scope to validate the request before the resolver is invoked. Configure API-scoped policies on the **API policies** tab for the API.
32+
* To support interface and union types in GraphQL resolvers, the backend response must either already contain the `__typename` field, or be altered using the [set-body](set-body-policy.md) policy to include `__typename`.
3233

3334
## Prerequisites
3435

articles/api-management/graphql-apis-overview.md

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

77
ms.service: api-management
88
ms.topic: conceptual
9-
ms.date: 09/18/2023
9+
ms.date: 05/05/2024
1010
ms.author: danlep
1111
---
1212

@@ -41,12 +41,13 @@ The GraphQL specification explicitly solves common issues experienced by client
4141

4242
Using a GraphQL API, the client app can specify the data they need to render a page in a query document that is sent as a single request to a GraphQL service. A client app can also subscribe to data updates pushed from the GraphQL service in real time.
4343

44-
## Schema and operation types
44+
## Schema and types
4545

4646
In API Management, add a GraphQL API from a GraphQL schema, either retrieved from a backend GraphQL API endpoint or uploaded by you. A GraphQL schema describes:
4747

4848
* Data object types and fields that clients can request from a GraphQL API
4949
* Operation types allowed on the data, such as queries
50+
* Other types, such as unions and interfaces, that provide additional flexibility and control over the data
5051

5152
For example, a basic GraphQL schema for user data and a query for all users might look like:
5253

@@ -61,17 +62,23 @@ type User {
6162
}
6263
```
6364

64-
API Management supports the following operation types in GraphQL schemas. For more information about these operation types, see the [GraphQL specification](https://spec.graphql.org/October2021/#sec-Subscription-Operation-Definitions).
65+
### Operation types
66+
67+
API Management supports the following operation types in GraphQL schemas. For more information about these operation types, see the [GraphQL specification](https://spec.graphql.org/October2021/#sec-Root-Operation-Types).
6568

6669
* **Query** - Fetches data, similar to a `GET` operation in REST
6770
* **Mutation** - Modifies server-side data, similar to a `PUT` or `PATCH` operation in REST
6871
* **Subscription** - Enables notifying subscribed clients in real time about changes to data on the GraphQL service
6972

7073
For example, when data is modified via a GraphQL mutation, subscribed clients could be automatically notified about the change.
7174

72-
> [!IMPORTANT]
73-
> API Management supports subscriptions implemented using the [graphql-ws](https://github.com/enisdenjo/graphql-ws) WebSocket protocol. Queries and mutations aren't supported over WebSocket.
74-
>
75+
> [!IMPORTANT]
76+
> API Management supports subscriptions implemented using the [graphql-ws](https://github.com/enisdenjo/graphql-ws) WebSocket protocol. Queries and mutations aren't supported over WebSocket.
77+
>
78+
79+
### Other types
80+
81+
API Management supports the [union](https://spec.graphql.org/October2021/#sec-Unions) and [interface](https://spec.graphql.org/October2021/#sec-Interfaces) types in GraphQL schemas.
7582

7683
## Resolvers
7784

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

Lines changed: 1 addition & 2 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/19/2024
9+
ms.date: 05/02/2024
1010
ms.author: danlep
1111
---
1212

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

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

102101
## Examples
103102

0 commit comments

Comments
 (0)