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

Create an API for GraphQL

To create an API for GraphQL:

  1. Open the database where you want to create a GraphQL API.

  2. Select New, and select GraphQL API.

    Screenshot from the Fabric portal showing the New button for database.

  3. 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.

  1. Select Get data. The Choose data screen allows you to search and choose the objects you want exposed in your GraphQL schema.

  2. 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.

    Screenshot from the Fabric portal showing the Choose data screen.

  3. Select Load to start the GraphQL schema generation process.

  4. 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.

    Screenshot from the Fabric portal showing the Schema explorer screen.

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.

Next step