Events
17 Mar, 9 pm - 21 Mar, 10 am
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
APPLIES TO: All API Management tiers
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.
In this article, you'll:
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.
An existing API Management instance. Create one if you haven't already.
A GraphQL API.
Azure CLI
Use the Bash environment in Azure Cloud Shell. For more information, see Quickstart for Bash in Azure Cloud Shell.
If you prefer to run CLI reference commands locally, install the Azure CLI. If you're running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see How to run the Azure CLI in a Docker container.
If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For other sign-in options, see Sign in with the Azure CLI.
When you're prompted, install the Azure CLI extension on first use. For more information about extensions, see Use extensions with the Azure CLI.
Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.
Azure PowerShell
In the Azure portal, navigate to your API Management instance.
In the left menu, select APIs > + Add API.
Under Define a new API, select the GraphQL icon.
In the dialog box, select Full and complete the required form fields.
Field | Description |
---|---|
Display name | The name by which your GraphQL API will be displayed. |
Name | Raw name of the GraphQL API. Automatically populates as you type the display name. |
GraphQL type | Select Pass-through GraphQL to import from an existing GraphQL API endpoint. |
GraphQL API endpoint | The base URL with your GraphQL API endpoint name. 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. |
Upload schema | Optionally select to browse and upload your schema file to replace the schema retrieved from the GraphQL endpoint (if available). |
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). |
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. |
Base URL | Uneditable field displaying your API base URL |
Tags | Associate your GraphQL API with new or existing tags. |
Products | Associate your GraphQL API with a product to publish it. |
Version this API? | Select to apply a versioning scheme to your GraphQL API. |
Select Create.
After the API is created, browse or modify the schema on the Design tab.
Navigate to your API Management instance.
From the side navigation menu, under the APIs section, select APIs.
Under All APIs, select your GraphQL API.
Select the Test tab to access the test console.
Under Headers:
If you've added a product to your GraphQL API, apply product scope under Apply product scope.
Under Query editor, either:
Select at least one field or subfield from the list in the side menu. The fields and subfields you select appear in the query editor.
Start typing in the query editor to compose a query.
Under Query variables, add variables to reuse the same query or mutation and pass different values.
Select Send.
View the Response.
Repeat preceding steps to test different payloads.
When testing is complete, exit test console.
If your GraphQL API supports a subscription, you can test it in the test console.
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.
Set up a subscription query in the query editor, and then select Connect to establish a WebSocket connection to the backend service.
Review connection details in the Subscription pane.
Subscribed events appear in the Subscription pane. The WebSocket connection is maintained until you disconnect it or you connect to a new WebSocket subscription.
Secure your GraphQL API by applying both existing authentication and authorization policies and a GraphQL validation policy to protect against GraphQL-specific attacks.
Events
17 Mar, 9 pm - 21 Mar, 10 am
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Get started with GraphQL in Microsoft Fabric - Training
Learn how GraphQL in Microsoft Fabric works, the key concepts, and practical examples to help users integrate their applications with GraphQL effectively as part of their solutions.
Certification
Microsoft Certified: Azure Cosmos DB Developer Specialty - Certifications
Write efficient queries, create indexing policies, manage, and provision resources in the SQL API and SDK with Microsoft Azure Cosmos DB.
Documentation
Support for GraphQL APIs - Azure API Management
Learn about GraphQL and how Azure API Management helps you manage GraphQL APIs.
Add a synthetic GraphQL API to Azure API Management
Add a synthetic GraphQL API by importing a GraphQL schema to API Management and configuring field resolvers that use HTTP-based data sources.
Configure GraphQL resolver in Azure API Management
Configure a GraphQL resolver in Azure API Management for a field in an object type specified in a GraphQL schema