This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreDid you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now
We are excited to announce the public preview of the new Microsoft Fabric API for GraphQL, which allows you to create and use APIs to interact with Fabric data in a simple, flexible, and powerful way. With Fabric API for GraphQL, data engineers and scientists can create a data API to connect to different data sources in seconds, use the APIs in their workflows, or share the API endpoints with app development teams to speed up business data analytics application development. In this blog post, we will show you how to use the new GraphQL API, how it can benefit enterprise application development, and help enhance your user experience. Whether you are new to GraphQL or already familiar with it, you will find this feature useful and easy to use. Let's get started!
A GraphQL API is defined in a Schema organized in terms of Types which contain Fields, as opposed to other types of APIs which are based on endpoints. GraphQL uses types to ensure applications only ask for what's possible and provide clear and helpful errors, helping to avoid writing manual parsing code. Types are used to describe the data and relationships with other types, with two special types in the schema defined to interact with data:
type Book {
id: ID!
title: String!
author: Author!
}
type Author { id: ID! name: String! books: [Book!]! }
type Query { books: [Book!]! book(id: ID!): Book author(id: ID!): Author }
type Mutation {
createBook(title: String!, authorId: ID!): Book!
updateBook(id: ID!, title: String): Book
deleteBook(id: ID!): Book
}
A client can send a single request to the GraphQL endpoint that fulfills a specific query to retrieve authors. All subsequent queries and mutations use the same endpoint, simplifying the client connection setup. After receiving a valid authorized request, the GraphQL engine connects to all data sources where the data is stored to retrieve specific fields defined in the query. The engine then constructs a single JSON response payload based on specific fields received from each data source and sends it back to the client, abstracting all the backend complexity and how many databases are used:
Unleashing_the_power_of_data_for_analytics_applications_with_the_new_Microsoft_F
Description automatically generated">
You can find more information about GraphQL schemas and types in the graphql.org website.
The new Fabric API for GraphQL allows to quicky expose data from one or multiple different Fabric data sources in seconds, automatically building a fully operational and secure GraphQL API with baked in enterprise best practices while abstracting all the API infrastructure setup and management complexity. The GraphQL schema, types, queries, mutations, and the business logic to access the data are all automatically generated based on selected data sources with built-in support for stored procedures, which can also be exposed via the API. GraphQL APIs in Fabric support the following data sources in the public preview:
Unleashing_the_power_of_data_for_analytics_applications_with_the_new_Microsoft_F
Description automatically generated" width="200" height="202">
Give your API a name and click Create to start the API creation process:
Unleashing_the_power_of_data_for_analytics_applications_with_the_new_Microsoft_F
Description automatically generated" width="300" height="180">
Now we need to feed our new API with data. Click on Select data source:
Unleashing_the_power_of_data_for_analytics_applications_with_the_new_Microsoft_F
Description automatically generated" width="300" height="199">
In this example we select an existing Warehouse (created with sample data as described in the documentation) then click Connect:
A_screenshot_of_a_computer
Next, we select the tables or stored procedures from the Warehouse we want to expose via GraphQL then click Load:
Unleashing_the_power_of_data_for_analytics_applications_with_the_new_Microsoft_F
Description automatically generated">
The GraphQL schema is automatically generated based on the selected tables and we can now start prototyping Queries or Mutations to read/write data in the API Editor with built-in IntelliSense/ code completion support to help us with the syntax:
Unleashing_the_power_of_data_for_analytics_applications_with_the_new_Microsoft_F
Description automatically generated">
It’s also possible to create relationships between types by selecting the ellipsis next to the data source, clicking on Manage relationships followed by New relationship:
Unleashing_the_power_of_data_for_analytics_applications_with_the_new_Microsoft_F
Define the cardinality, types and fields then click on Create relationship. In this example we create a relationship between Weather and Geography where a type of weather can happen in multiple geographies:
Unleashing_the_power_of_data_for_analytics_applications_with_the_new_Microsoft_F
Description automatically generated">
We’re ready to test the relationship we created with a new query. A single query to the GraphQL endpoint fans out to two different tables (Weather and Geography) then joins the results accordingly in a familiar JSON format:
Unleashing_the_power_of_data_for_analytics_applications_with_the_new_Microsoft_F
Description automatically generated">
Once the GraphQL API is ready, we can share the endpoint with analytics development teams to integrate with their applications by clicking on Copy endpoint at the top of the Schema Explorer. In addition to the endpoint, applications require a Tenant ID and a Client ID to authorize API calls to the GraphQL endpoint. You can find more information on how to retrieve IDs from Microsoft Entra here.
Unleashing_the_power_of_data_for_analytics_applications_with_the_new_Microsoft_F
Description automatically generated" width="300" height="207">
Fabric generates a fully-fledged scalable GraphQL API in seconds based on specific data you want to expose to enterprise applications with secure access based on managed identities. Microsoft Fabric API for GraphQL is currently in Public Preview and free to use until July 1st 2024, after which API calls (queries/mutations) will count against your Capacity Units usage. You can find more information about GraphQL in Fabric in our documentation.
How will you use the new GraphQL integration in your next Fabric project? What else would you like to see in the Microsoft Fabric API for GraphQL? Share with us in the comments section below.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.