Skip to content

Commit 272adf5

Browse files
Merge pull request #227058 from dlepow/gqlgaover
[APIM][GraphQL GA] Conceptual updates
2 parents a77b537 + 787e50f commit 272adf5

8 files changed

+432
-24
lines changed

articles/api-management/TOC.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
href: devops-api-development-templates.md
8989
- name: APIs
9090
items:
91+
- name: GraphQL APIs
92+
href: graphql-apis-overview.md
9193
- name: API design ebook
9294
href: https://azure.microsoft.com/mediahandler/files/resourcefiles/api-design/Azure_API-Design_Guide_eBook.pdf?toc=%2Fazure%2Fapi-management%2Ftoc.json&bc=/azure/api-management/breadcrumb/toc.json
9395
- name: RESTful web API design
@@ -436,6 +438,8 @@
436438
href: forward-request-policy.md
437439
- name: get-authorization-context
438440
href: get-authorization-context-policy.md
441+
- name: http-data-source
442+
href: http-data-source-policy.md
439443
- name: include-fragment
440444
href: include-fragment-policy.md
441445
- name: invoke-dapr-binding
@@ -452,6 +456,8 @@
452456
href: mock-response-policy.md
453457
- name: proxy
454458
href: proxy-policy.md
459+
- name: publish-event
460+
href: publish-event-policy.md
455461
- name: publish-to-dapr
456462
href: publish-to-dapr-policy.md
457463
- name: quota

articles/api-management/api-management-features.md

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

88
ms.service: api-management
99
ms.topic: article
10-
ms.date: 02/07/2022
10+
ms.date: 02/22/2023
1111
ms.author: danlep
1212
---
1313

@@ -38,12 +38,11 @@ Each API Management [pricing tier](https://aka.ms/apimpricing) offers a distinct
3838
| Direct management API | No | Yes | Yes | Yes | Yes |
3939
| Azure Monitor logs and metrics | No | Yes | Yes | Yes | Yes |
4040
| Static IP | No | Yes | Yes | Yes | Yes |
41-
| [WebSocket APIs](websocket-api.md) | No | Yes | Yes | Yes | Yes |
42-
| [GraphQL APIs](graphql-api.md)<sup>5</sup> | Yes | Yes | Yes | Yes | Yes |
43-
| [Synthetic GraphQL APIs (preview)](graphql-schema-resolve-api.md) | No | Yes | Yes | Yes | Yes |
41+
| [Pass-through WebSocket APIs](websocket-api.md) | No | Yes | Yes | Yes | Yes |
42+
| [Pass-through GraphQL APIs](graphql-apis-overview.md) | Yes | Yes | Yes | Yes | Yes |
43+
| [Synthetic GraphQL APIs](graphql-apis-overview.md) | Yes | Yes | Yes | Yes | Yes |
4444

4545
<sup>1</sup> Enables the use of Azure AD (and Azure AD B2C) as an identity provider for user sign in on the developer portal.<br/>
4646
<sup>2</sup> Including related functionality such as users, groups, issues, applications, and email templates and notifications.<br/>
4747
<sup>3</sup> See [Gateway overview](api-management-gateways-overview.md#feature-comparison-managed-versus-self-hosted-gateways) for a feature comparison of managed versus self-hosted gateways. In the Developer tier self-hosted gateways are limited to a single gateway node. <br/>
48-
<sup>4</sup> The following policies aren't available in the Consumption tier: rate limit by key and quota by key. <br/>
49-
<sup>5</sup> GraphQL subscriptions aren't supported in the Consumption tier.
48+
<sup>4</sup> The following policies aren't available in the Consumption tier: rate limit by key and quota by key.

articles/api-management/api-management-gateways-overview.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author: dlepow
77

88
ms.service: api-management
99
ms.topic: conceptual
10-
ms.date: 08/04/2022
10+
ms.date: 02/22/2023
1111
ms.author: danlep
1212
---
1313

@@ -91,11 +91,9 @@ The following table compares features available in the managed gateway versus th
9191
| [Function App](import-function-app-as-api.md) | ✔️ | ✔️ | ✔️ |
9292
| [Container App](import-container-app-with-oas.md) | ✔️ | ✔️ | ✔️ |
9393
| [Service Fabric](../service-fabric/service-fabric-api-management-overview.md) | Developer, Premium |||
94-
| [Passthrough GraphQL](graphql-api.md) | ✔️ | ✔️<sup>1</sup> ||
95-
| [Synthetic GraphQL](graphql-schema-resolve-api.md) | ✔️ |||
96-
| [Passthrough WebSocket](websocket-api.md) | ✔️ |||
97-
98-
<sup>1</sup> GraphQL subscriptions aren't supported in the Consumption tier.
94+
| [Pass-through GraphQL](graphql-apis-overview.md) | ✔️ | ✔️ ||
95+
| [Synthetic GraphQL](graphql-apis-overview.md)| ✔️ | ✔️ ||
96+
| [Pass-through WebSocket](websocket-api.md) | ✔️ |||
9997

10098
### Policies
10199

@@ -104,9 +102,9 @@ Managed and self-hosted gateways support all available [policies](api-management
104102
| Policy | Managed (Dedicated) | Managed (Consumption) | Self-hosted<sup>1</sup> |
105103
| --- | ----- | ----- | ---------- |
106104
| [Dapr integration](api-management-policies.md#dapr-integration-policies) ||| ✔️ |
105+
| [GraphQL resolvers](api-management-policies.md#graphql-resolver-policies) and [GraphQL validation](api-management-policies.md#validation-policies)| ✔️ | ✔️ ||
107106
| [Get authorization context](get-authorization-context-policy.md) | ✔️ | ✔️ ||
108107
| [Quota and rate limit](api-management-policies.md#access-restriction-policies) | ✔️ | ✔️<sup>2</sup> | ✔️<sup>3</sup>
109-
| [Set GraphQL resolver](set-graphql-resolver-policy.md) | ✔️ |||
110108

111109
<sup>1</sup> Configured policies that aren't supported by the self-hosted gateway are skipped during policy execution.<br/>
112110
<sup>2</sup> The rate limit by key and quota by key policies aren't available in the Consumption tier.<br/>

articles/api-management/api-management-policies.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ More information about policies:
7373
- [Send message to Pub/Sub topic](publish-to-dapr-policy.md): Uses Dapr runtime to publish a message to a Publish/Subscribe topic. To learn more about Publish/Subscribe messaging in Dapr, see the description in this [README](https://github.com/dapr/docs/blob/master/README.md) file.
7474
- [Trigger output binding](invoke-dapr-binding-policy.md): Uses Dapr runtime to invoke an external system via output binding. To learn more about bindings in Dapr, see the description in this [README](https://github.com/dapr/docs/blob/master/README.md) file.
7575

76-
## GraphQL API policies
77-
- [Validate GraphQL request](validate-graphql-request-policy.md) - Validates and authorizes a request to a GraphQL API.
78-
- [Set GraphQL resolver](set-graphql-resolver-policy.md) - Retrieves or sets data for a GraphQL field in an object type specified in a GraphQL schema.
76+
## GraphQL resolver policies
77+
- [Publish event to GraphQL subscription](publish-event-policy.md) - Publishes an event to one or more subscriptions specified in a GraphQL API schema. Used in the `http-response` element of the `http-data-source` policy
7978

8079
## Transformation policies
8180
- [Convert JSON to XML](json-to-xml-policy.md) - Converts request or response body from JSON to XML.
@@ -92,6 +91,7 @@ More information about policies:
9291
## Validation policies
9392

9493
- [Validate content](validate-content-policy.md) - Validates the size or content of a request or response body against one or more API schemas. The supported schema formats are JSON and XML.
94+
- [Validate GraphQL request](validate-graphql-request-policy.md) - Validates and authorizes a request to a GraphQL API.
9595
- [Validate parameters](validate-parameters-policy.md) - Validates the request header, query, or path parameters against the API schema.
9696
- [Validate headers](validate-headers-policy.md) - Validates the response headers against the API schema.
9797
- [Validate status code](validate-status-code-policy.md) - Validates the HTTP status codes in
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
title: Support for GraphQL APIs - Azure API Management
3+
description: Learn about GraphQL and how Azure API Management helps you manage GraphQL APIs.
4+
services: api-management
5+
author: dlepow
6+
7+
ms.service: api-management
8+
ms.topic: conceptual
9+
ms.date: 02/14/2023
10+
ms.author: danlep
11+
---
12+
13+
# Overview of GraphQL APIs in Azure API Management
14+
15+
You can use API Management to manage GraphQL APIs - APIs based on the GraphQL query language. GraphQL provides a complete and understandable description of the data in an API, giving clients the power to efficiently retrieve exactly the data they need. [Learn more about GraphQL]( https://graphql.org/learn/)
16+
17+
API Management helps you import, manage, protect, test, publish, and monitor GraphQL APIs. You can choose one of two API models:
18+
19+
20+
|Pass-through GraphQL |Synthetic GraphQL |
21+
|---------|---------|
22+
| ▪️ Pass-through API to existing GraphQL service endpoint<br><br/>▪️ Support for GraphQL queries, mutations, and subscriptions | ▪️ API based on a custom GraphQL schema<br></br>▪️ Support for GraphQL queries, mutations, and subscriptions<br/><br/>▪️ Configure custom resolvers, for example, to HTTP data sources<br/><br/>▪️ Develop GraphQL schemas and GraphQL-based clients while consuming data from legacy APIs |
23+
24+
## Availability
25+
26+
* GraphQL APIs are supported in all API Management service tiers
27+
* Pass-through and synthetic GraphQL APIs currently aren't supported in a self-hosted gateway
28+
* GraphQL subscription support in synthetic GraphQL APIs is currently in preview
29+
30+
## What is GraphQL?
31+
32+
GraphQL is an open-source, industry-standard query language for APIs. Unlike REST-style APIs designed around actions over resources, GraphQL APIs support a broader set of use cases and focus on data types, schemas, and queries.
33+
34+
The GraphQL specification explicitly solves common issues experienced by client web apps that rely on REST APIs:
35+
36+
* It can take a large number of requests to fulfill the data needs for a single page
37+
* REST APIs often return more data than needed the page being rendered
38+
* The client app needs to poll to get new information
39+
40+
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.
41+
42+
## Schema and operation types
43+
44+
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:
45+
46+
* Data object types and fields that clients can request from a GraphQL API
47+
* Operation types allowed on the data, such as queries
48+
49+
For example, a basic GraphQL schema for user data and a query for all users might look like:
50+
51+
```
52+
type Query {
53+
users: [User]
54+
}
55+
56+
type User {
57+
id: String!
58+
name: String!
59+
}
60+
```
61+
62+
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).
63+
64+
* **Query** - Fetches data, similar to a `GET` operation in REST
65+
* **Mutation** - Modifies server-side data, similar to a `PUT` or `PATCH` operation in REST
66+
* **Subscription** - Enables notifying subscribed clients in real time about changes to data on the GraphQL service
67+
68+
For example, when data is modified via a GraphQL mutation, subscribed clients could be automatically notified about the change.
69+
70+
> [!IMPORTANT]
71+
> 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.
72+
>
73+
74+
## Resolvers
75+
76+
*Resolvers* take care of mapping the GraphQL schema to backend data, producing the data for each field in an object type. The data source could be an API, a database, or another service. For example, a resolver function would be responsible for returning data for the `users` query in the preceding example.
77+
78+
In API Management, you can create a *custom resolver* to map a field in an object type to a backend data source. You configure resolvers for fields in synthetic GraphQL API schemas, but you can also configure them to override the default field resolvers used by pass-through GraphQL APIs.
79+
80+
API Management currently supports HTTP-based resolvers to return the data for fields in a GraphQL schema. To use an HTTP-based resolver, configure a [`http-data-source`](http-data-source-policy.md) policy that transforms the API request (and optionally the response) into an HTTP request/response.
81+
82+
For example, a resolver for the preceding `users` query might map to a `GET` operation in a backend REST API:
83+
84+
```xml
85+
<http-data-source>
86+
<http-request>
87+
<set-method>GET</set-method>
88+
<set-url>https://myapi.contoso.com/api/users</set-url>
89+
</http-request>
90+
</http-data-source>
91+
```
92+
93+
## Manage GraphQL APIs
94+
95+
* Secure GraphQL APIs by applying both existing access control policies and a [GraphQL validation policy](validate-graphql-request-policy.md) to secure and protect against GraphQL-specific attacks.
96+
* Explore the GraphQL schema and run test queries against the GraphQL APIs in the Azure and developer portals.
97+
98+
99+
## Next steps
100+
101+
- [Import a GraphQL API](graphql-api.md)
102+
- [Import a GraphQL schema and set up field resolvers](graphql-schema-resolve-api.md)

0 commit comments

Comments
 (0)