Import a GraphQL API (preview)
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.
API Management tackles the security, authentication, and authorization challenges that come with publishing GraphQL APIs. Using API Management to expose your GraphQL APIs, you can:
- Add a GraphQL service as APIs via Azure portal.
- Secure GraphQL APIs by applying both existing access control policies and a new policy to secure and protect against GraphQL-specific attacks.
- Explore the schema and run test queries against the GraphQL APIs in the Azure and developer portals.
Important
API Management GraphQL API is currently in preview.
In this article, you'll:
- Learn more about the benefits of using GraphQL APIs.
- Add a GraphQL API to your API Management instance.
- Test your GraphQL API.
- Learn the limitations of your GraphQL API in API Management.
Prerequisites
- An existing API Management instance. Create one if you haven't already.
- A GraphQL API.
Add a GraphQL API
Navigate to your API Management instance.
From the side navigation menu, under the APIs section, select APIs.
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 API endpoint The base URL with your GraphQL API endpoint name.
For example:https://example.com/your-GraphQL-name. You can also use the common "Star Wars" GraphQL endpoint as a demo.Upload schema file Select to browse and upload your schema file. Description Add a description of your API. URL scheme Select HTTP, HTTPS, or Both. Default selection: Both. 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. Gateways Associate your GraphQL API with existing gateways. Default gateway selection: Managed. Version this API? Select to version control your GraphQL API. Click Create.
Test your GraphQL API
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:
- Select the header from the Name drop-down menu.
- Enter the value to the Value field.
- Add more headers by selecting + Add header.
- Delete headers using the trashcan icon.
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.
Click Send.
View the Response.
Repeat preceding steps to test different payloads.
When testing is complete, exit test console.
Limitations
- Only GraphQL pass through is supported.
- A single GraphQL API in API Management corresponds to only a single GraphQL backend endpoint.
Related topics
- API import limitations
- Import an OpenAPI specification
- Import a SOAP API
- Import a SOAP API and convert to REST
- Import an App Service API
- Import a Container App API
- Import a WebSocket API
- Import a GraphQL API (preview)
- Import an Azure Function App
- Import an Azure Logic App
- Import a Service Fabric service
- Edit an API