Breyta

Deila með


Create an API for GraphQL in Fabric and add data

Note

Microsoft Fabric API for GraphQL is in preview.

Get started with the Fabric API for GraphQL by creating an API, then linking a data source to expose the data you chose through the API. Fabric builds the GraphQL schema automatically based on your data, and applications are ready to connect in minutes.

Prerequisites

Creating an API for GraphQL

To create an API for GraphQL:

  1. From the Fabric portal home page, select Data Engineering from the list of workloads.

  2. Select API for GraphQL (Preview).

    Screenshot of the API tile, which you select to create a new API item.

    Alternatively, select New > API for GraphQL (Preview) from any workspace in Data Engineering.

    Screenshot of the workspace toolbar, showing where to select the New option.

  3. Enter a Name for your item and select Create.

    Screenshot of the New API for GraphQL dialog box, showing where to enter the Name and select Create.

You now have a fully functional API to access your data in Fabric.

Connect to a data source and build your schema

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. In your new API, choose a data source to expose by choosing Select data source.

    Screenshot of the Select data source option.

  2. The OneLake data hub appears; choose the data source you want to connect to. For the following example, we choose a AdventureWorks SQL analytics endpoint linked to a mirrored database. Select Filter to see only specific types of Fabric data sources, or search by a specific keyword. When you're ready, select Connect.

    Screenshot of the OneLake data hub, showing available data source options for a workspace.

  3. The Get data screen appears, where you can choose which objects you want exposed in your GraphQL schema.

    Screenshot of the Get data screen showing the Choose data list.

  4. 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 of the Choose data list with a folder selected, which automatically selects all items inside that folder.

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

  6. The schema is generated and you can start prototyping GraphQL queries (read, list) or mutations (create, update, delete) to interact with your data.

    Screenshot of 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.