You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/api-management/graphql-api.md
+4-6Lines changed: 4 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: Import a GraphQL API to Azure API Management | Microsoft Docs
2
+
title: Add a GraphQL API to Azure API Management | Microsoft Docs
3
3
titleSuffix:
4
4
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.
> * Add a GraphQL API to your API Management instance.
19
+
> * Add a pass-through GraphQL API to your API Management instance.
20
20
> * Test your GraphQL API.
21
-
> * Learn the limitations of your GraphQL API in API Management.
22
21
23
22
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).
24
23
@@ -55,16 +54,15 @@ If you want to import a GraphQL schema and set up field resolvers using REST or
55
54
|**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. |
56
55
|**Upload schema**| Optionally select to browse and upload your schema file to replace the schema retrieved from the GraphQL endpoint (if available). |
57
56
|**Description**| Add a description of your API. |
|**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)*. |
59
58
|**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. |
60
59
|**Base URL**| Uneditable field displaying your API base URL |
61
60
|**Tags**| Associate your GraphQL API with new or existing tags. |
62
61
|**Products**| Associate your GraphQL API with a product to publish it. |
63
-
|**Gateways**| Associate your GraphQL API with existing gateways. Default gateway selection: *Managed*. |
64
62
|**Version this API?**| Select to apply a versioning scheme to your GraphQL API. |
65
63
66
64
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.
68
66
:::image type="content" source="media/graphql-api/explore-schema.png" alt-text="Screenshot of exploring the GraphQL schema in the portal.":::
Copy file name to clipboardExpand all lines: articles/api-management/graphql-schema-resolve-api.md
+30-22Lines changed: 30 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
1
---
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
3
3
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.
5
5
ms.service: api-management
6
6
author: dlepow
7
7
ms.author: danlep
8
8
ms.topic: how-to
9
-
ms.date: 05/17/2022
9
+
ms.date: 02/21/2023
10
10
ms.custom: event-tier1-build-2022
11
11
---
12
12
13
-
# Import a GraphQL schema and set up field resolvers
13
+
# Add a synthetic GraphQL API and set up field resolvers
> * 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
24
24
> * Test your GraphQL API
25
25
26
26
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
45
45
46
46
:::image type="content" source="media/graphql-schema-resolve-api/create-from-graphql-schema.png" alt-text="Screenshot of fields for creating a GraphQL API.":::
47
47
48
-
| Field | Description |
48
+
| Field | Description |
49
49
|----------------|-------|
50
50
|**Display name**| The name by which your GraphQL API will be displayed. |
51
51
|**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.|
|**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)*. |
56
56
|**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. |
57
57
|**Base URL**| Uneditable field displaying your API base URL |
58
58
|**Tags**| Associate your GraphQL API with new or existing tags. |
59
59
|**Products**| Associate your GraphQL API with a product to publish it. |
60
-
|**Gateways**| Associate your GraphQL API with existing gateways. Default gateway selection: *Managed*. |
61
60
|**Version this API?**| Select to apply a versioning scheme to your GraphQL API. |
61
+
62
62
63
63
1. Select **Create**.
64
64
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.
66
66
67
67
## Configure resolver
68
68
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 -->
70
72
71
73
Suppose you imported the following basic GraphQL schema and wanted to set up a resolver for the *users* query.
72
74
@@ -82,24 +84,30 @@ type User {
82
84
```
83
85
84
86
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.":::
88
93
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.
90
95
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.
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.
Copy file name to clipboardExpand all lines: includes/api-management-graphql-intro.md
+3-15Lines changed: 3 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,21 +3,9 @@ ms.service: api-management
3
3
ms.topic: include
4
4
author: dlepow
5
5
ms.author: danlep
6
-
ms.date: 05/17/2022
6
+
ms.date: 02/21/2023
7
7
ms.custom:
8
8
---
9
9
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.
Copy file name to clipboardExpand all lines: includes/api-management-graphql-test.md
+14-5Lines changed: 14 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,8 +34,17 @@ ms.custom:
34
34
1. Repeat preceding steps to test different payloads.
35
35
1. When testing is complete, exit test console.
36
36
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.":::
0 commit comments