Skip to content

Commit ec4a37a

Browse files
committed
[APIM][GraphQL GA] How-to updates
1 parent 53f8540 commit ec4a37a

13 files changed

+51
-48
lines changed

articles/api-management/graphql-api.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Import a GraphQL API to Azure API Management | Microsoft Docs
2+
title: Add a GraphQL API to Azure API Management | Microsoft Docs
33
titleSuffix:
44
description: Learn how to add an existing GraphQL service as an API in Azure API Management using the Azure portal, Azure CLI, or Azure PowerShell. Manage the API and enable queries to pass through to the GraphQL endpoint.
55
ms.service: api-management
@@ -16,9 +16,8 @@ ms.custom: event-tier1-build-2022
1616

1717
In this article, you'll:
1818
> [!div class="checklist"]
19-
> * Add a GraphQL API to your API Management instance.
19+
> * Add a pass-through GraphQL API to your API Management instance.
2020
> * Test your GraphQL API.
21-
> * Learn the limitations of your GraphQL API in API Management.
2221
2322
If you want to import a GraphQL schema and set up field resolvers using REST or SOAP API endpoints, see [Import a GraphQL schema and set up field resolvers](graphql-schema-resolve-api.md).
2423

@@ -55,16 +54,15 @@ If you want to import a GraphQL schema and set up field resolvers using REST or
5554
| **GraphQL API endpoint** | The base URL with your GraphQL API endpoint name. <br /> For example: *`https://example.com/your-GraphQL-name`*. You can also use a common "swapi" GraphQL endpoint such as `https://swapi-graphql.azure-api.net/graphql` as a demo. |
5655
| **Upload schema** | Optionally select to browse and upload your schema file to replace the schema retrieved from the GraphQL endpoint (if available). |
5756
| **Description** | Add a description of your API. |
58-
| **URL scheme** | Select **HTTP**, **HTTPS**, or **HTTP(S)**. Default selection: *HTTP(S)*. |
57+
| **URL scheme** | Make a selection based on your GraphQL endpoint. Select one of the options that includes a WebSocket scheme (**WS** or **WSS**) if your GraphQL API includes the subscription type. Default selection: *HTTP(S)*. |
5958
| **API URL suffix**| Add a URL suffix to identify this specific API in this API Management instance. It has to be unique in this API Management instance. |
6059
| **Base URL** | Uneditable field displaying your API base URL |
6160
| **Tags** | Associate your GraphQL API with new or existing tags. |
6261
| **Products** | Associate your GraphQL API with a product to publish it. |
63-
| **Gateways** | Associate your GraphQL API with existing gateways. Default gateway selection: *Managed*. |
6462
| **Version this API?** | Select to apply a versioning scheme to your GraphQL API. |
6563

6664
1. Select **Create**.
67-
1. After the API is created, browse the schema on the **Design** tab, in the **Frontend** section.
65+
1. After the API is created, browse or modify the schema on the **Design** tab.
6866
:::image type="content" source="media/graphql-api/explore-schema.png" alt-text="Screenshot of exploring the GraphQL schema in the portal.":::
6967

7068
#### [Azure CLI](#tab/cli)

articles/api-management/graphql-schema-resolve-api.md

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
2-
title: Import GraphQL schema and set up field resolvers | Microsoft Docs
2+
title: Add a synthetic GraphQL API to Azure API Management | Microsoft Docs
33
titleSuffix:
4-
description: Import a GraphQL schema to API Management and configure a policy to resolve a GraphQL query using an HTTP-based data source.
4+
description: Add a synthetic GraphQL API by importing a GraphQL schema to API Management and configuring field resolvers that use HTTP-based data sources.
55
ms.service: api-management
66
author: dlepow
77
ms.author: danlep
88
ms.topic: how-to
9-
ms.date: 05/17/2022
9+
ms.date: 02/21/2023
1010
ms.custom: event-tier1-build-2022
1111
---
1212

13-
# Import a GraphQL schema and set up field resolvers
13+
# Add a synthetic GraphQL API and set up field resolvers
1414

1515

1616
[!INCLUDE [api-management-graphql-intro.md](../../includes/api-management-graphql-intro.md)]
@@ -20,7 +20,7 @@ ms.custom: event-tier1-build-2022
2020
In this article, you'll:
2121
> [!div class="checklist"]
2222
> * Import a GraphQL schema to your API Management instance
23-
> * Set up a resolver for a GraphQL query using an existing HTTP endpoints
23+
> * Set up a resolver for a GraphQL query using an existing HTTP endpoint
2424
> * Test your GraphQL API
2525
2626
If you want to expose an existing GraphQL endpoint as an API, see [Import a GraphQL API](graphql-api.md).
@@ -45,28 +45,30 @@ If you want to expose an existing GraphQL endpoint as an API, see [Import a Grap
4545

4646
:::image type="content" source="media/graphql-schema-resolve-api/create-from-graphql-schema.png" alt-text="Screenshot of fields for creating a GraphQL API.":::
4747

48-
| Field | Description |
48+
| Field | Description |
4949
|----------------|-------|
5050
| **Display name** | The name by which your GraphQL API will be displayed. |
5151
| **Name** | Raw name of the GraphQL API. Automatically populates as you type the display name. |
52-
| **Fallback GraphQL endpoint** | For this scenario, optionally enter a URL with a GraphQL API endpoint name. API Management passes GraphQL queries to this endpoint when a custom resolver isn't set for a field. |
53-
| **Upload schema file** | Select to browse and upload a valid GraphQL schema file with the `.graphql` extension. |
54-
| Description | Add a description of your API. |
55-
| URL scheme | Select **HTTP**, **HTTPS**, or **Both**. Default selection: *Both*. |
52+
| **GraphQL type** | Select **Synthetic GraphQL** to import from a GraphQL schema file. |
53+
| **Fallback GraphQL endpoint** | Optionally enter a URL with a GraphQL API endpoint name. API Management passes GraphQL queries to this endpoint when a custom resolver isn't set for a field. |
54+
| **Description** | Add a description of your API. |
55+
| **URL scheme** | Make a selection based on your GraphQL endpoint. Select one of the options that includes a WebSocket scheme (**WS** or **WSS**) if your GraphQL API includes the subscription type. Default selection: *HTTP(S)*. |
5656
| **API URL suffix**| Add a URL suffix to identify this specific API in this API Management instance. It has to be unique in this API Management instance. |
5757
| **Base URL** | Uneditable field displaying your API base URL |
5858
| **Tags** | Associate your GraphQL API with new or existing tags. |
5959
| **Products** | Associate your GraphQL API with a product to publish it. |
60-
| **Gateways** | Associate your GraphQL API with existing gateways. Default gateway selection: *Managed*. |
6160
| **Version this API?** | Select to apply a versioning scheme to your GraphQL API. |
61+
6262

6363
1. Select **Create**.
6464

65-
1. After the API is created, browse the schema on the **Design** tab, in the **Frontend** section.
65+
1. After the API is created, browse or modify the schema on the **Design** tab.
6666

6767
## Configure resolver
6868

69-
Configure the [set-graphql-resolver](set-graphql-resolver-policy.md) policy to map a field in the schema to an existing HTTP endpoint.
69+
Configure a resolver to map a field in the schema to an existing HTTP endpoint.
70+
71+
<!-- Add link to resolver how-to article for details -->
7072

7173
Suppose you imported the following basic GraphQL schema and wanted to set up a resolver for the *users* query.
7274

@@ -82,24 +84,30 @@ type User {
8284
```
8385

8486
1. From the side navigation menu, under the **APIs** section, select **APIs** > your GraphQL API.
85-
1. On the **Design** tab of your GraphQL API, select **All operations**.
86-
1. In the **Backend** processing section, select **+ Add policy**.
87-
1. Configure the `set-graphql-resolver` policy to resolve the *users* query using an HTTP data source.
87+
1. On the **Design** tab, review the schema for a field in an object type where you want to configure a resolver.
88+
1. Select a field, and then in th
89+
1. left margin, hover the pointer.
90+
1. Select **+ Add Resolver**
91+
92+
:::image type="content" source="media/graphql-schema-resolve-api/add-resolver.png" alt-text="Screenshot of adding a GraphQL resolver in the portal.":::
8893

89-
For example, the following `set-graphql-resolver` policy retrieves the *users* field by using a `GET` call on an existing HTTP data source.
94+
1. On the **Create Resolver** page, update the **Name** property if you want to, optionally enter a **Description**, and confirm or update the **Type** and **Field** selections.
9095

96+
1. In the **Resolver policy** editor, update the `<http-data-source>` element with child elements for your scenario. For example, the following resolver retrieves the *users* field by using a `GET` call on an existing HTTP data source.
97+
98+
9199
```xml
92-
<set-graphql-resolver parent-type="Query" field="users">
93100
<http-data-source>
94101
<http-request>
95102
<set-method>GET</set-method>
96103
<set-url>https://myapi.contoso.com/users</set-url>
97104
</http-request>
98-
</http-data-source>
99-
</set-graphql-resolver>
105+
</http-data-source>\
100106
```
101-
1. To resolve data for other fields in the schema, repeat the preceding step.
102-
1. Select **Save**.
107+
108+
:::image type="content" source="media/graphql-schema-resolve-api/configure-resolver-policy.png" alt-text="Screenshot of configuring resolver policy in the portal.":::
109+
1. Select **Create**.
110+
1. To resolve data for other fields in the schema, repeat the preceding steps to create a resolver.
103111

104112
[!INCLUDE [api-management-graphql-test.md](../../includes/api-management-graphql-test.md)]
105113

-28.9 KB
Loading
39.4 KB
Loading
45.7 KB
Loading
-48.5 KB
Loading

includes/api-management-graphql-intro.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,9 @@ ms.service: api-management
33
ms.topic: include
44
author: dlepow
55
ms.author: danlep
6-
ms.date: 05/17/2022
6+
ms.date: 02/21/2023
77
ms.custom:
88
---
99

10-
GraphQL is an open-source, industry-standard query language for APIs. Unlike endpoint-based (or 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.
11-
12-
Using API Management to expose your GraphQL APIs, you can:
13-
* Add a GraphQL endpoint or GraphQL schema as an API via the Azure portal, the Azure CLI, or other Azure tools.
14-
* (Preview) Augment or design a GraphQL API using information from REST or SOAP APIs, using [HTTP resolvers](../articles/api-management/set-graphql-resolver-policy.md) for fields defined in a GraphQL schema.
15-
* Secure GraphQL APIs by applying both existing access control policies and a [GraphQL validation policy](../articles/api-management/validate-graphql-request-policy.md) to secure and protect against GraphQL-specific attacks.
16-
* Explore the schema and run test queries against the GraphQL APIs in the Azure and developer portals.
17-
18-
> [!NOTE]
19-
> * A single GraphQL API in API Management can map to a single GraphQL backend endpoint.
20-
> * A GraphQL API requires a GraphQL schema, either from an existing GraphQL endpoint or uploaded by you.
21-
> * API Management supports query, mutation, and subscription operation types in GraphQL schemas.
22-
> * Subscriptions are not supported in the **Consumption** service tier.
23-
> * A subscription must be implemented using the [graphql-ws](https://github.com/enisdenjo/graphql-ws) WebSocket protocol. Queries and mutations are not supported over WebSocket.
10+
In API Management, you can add a GraphQL API in one of two models: pass-through to an existing GraphQL endpoint, or import a GraphQL schema and create a synthetic GraphQL API with custom field resolvers. For more information, see the GraphQL overview.
11+
<!-- Add link to GraphQL overview when merged -->

includes/api-management-graphql-test.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,17 @@ ms.custom:
3434
1. Repeat preceding steps to test different payloads.
3535
1. When testing is complete, exit test console.
3636

37-
> [!NOTE]
38-
> You can test a subscription in the test console:
39-
> * Set up a subscription query in the query editor, and then select **Connect** to establish a WebSocket connection to the backend service.
40-
> * Review connection details in the **Subscription** pane.
41-
> * The WebSocket connection is maintained until you disconnect it or you connect to a new WebSocket subscription.
37+
## Test a subscription
38+
If your GraphQL schema includes a subscription, you can test it in the test console
39+
40+
1. Ensure that your API allows a WebSocket URL scheme (**WS** or **WSS**) that's appropriate for your API. You can enable this setting on the **Settings** tab.
41+
1. Set up a subscription query in the query editor, and then select **Connect** to establish a WebSocket connection to the backend service.
42+
43+
:::image type="content" source="media/api-management-graphql-test/test-graphql-subscription.png" alt-text="Screenshot of a subscription query in the query editor.":::
44+
1. Review connection details in the **Subscription** pane.
45+
46+
:::image type="content" source="media/api-management-graphql-test/graphql-websocket-connection.png" alt-text="Screenshot of Websocket connection in the portal.":::
47+
48+
1. Subscribed events appear in the **Subscription** pane. The WebSocket connection is maintained until you disconnect it or you connect to a new WebSocket subscription.
49+
50+
:::image type="content" source="media/api-management-graphql-test/graphql-subscription-event.png" alt-text="Screenshot of GraphQL subscription events in the portal.":::
-21.2 KB
Loading
67.2 KB
Loading

0 commit comments

Comments
 (0)