Create GraphQL API from your SQL database in the Fabric portal
Applies to: ✅ SQL database in Microsoft Fabric
Start building GraphQL APIs directly from within the Fabric SQL query editor. Fabric builds the GraphQL schema automatically based on your data, and applications are ready to connect in minutes.
Prerequisites
- You need an existing Fabric capacity. If you don't, start a Fabric trial.
- Make sure that you Enable SQL database in Fabric using Admin Portal tenant settings.
- Create a new workspace or use an existing Fabric workspace.
- Create a new SQL database or use an existing SQL database.
Create an API for GraphQL
To create an API for GraphQL:
Open the database where you want to create a GraphQL API.
Select New, and select GraphQL API.
Enter a Name for your item and select Create.
At this point, the API is ready but it's not exposing any data. APIs for GraphQL are defined in a schema organized in terms of types and fields, in a strongly typed system. Fabric automatically generates the necessary GraphQL schema based on the data you choose to expose to GraphQL clients.
Select Get data. The Choose data screen allows you to search and choose the objects you want exposed in your GraphQL schema.
Select the checkboxes next to the individual tables or stored procedures you want to expose in the API. To select all the objects in a folder, select the checkbox with the data source name at the top.
Select Load to start the GraphQL schema generation process.
The schema is generated, and you can start prototyping GraphQL queries (read, list) or mutations (create, update, delete) to interact with your data. The following image shows the Schema explorer with an API call template.
Your API for GraphQL is now ready to accept connections and requests. You can use the API editor to test and prototype GraphQL queries and the Schema explorer to verify the data types and fields exposed in the API.