Access your š— š—¶š—°š—æš—¼š˜€š—¼š—³š˜ š—™š—®š—Æš—æš—¶š—° Data with external applications using "š—šš—æš—®š—½š—µš—¤š—Ÿ" š—½š—¹š—®š˜†š—“š—æš—¼š˜‚š—»š—±

Picture this : you've got valuable data locked away in Microsoft Fabric, perfectly organized and secure. But now you need to share that data with external applications, power dynamic dashboards, or integrate with third-party tools. The question that keeps every data engineer up at night is: how do you provide secure, efficient external access to only authorized parties?

If you've been wrestling with this challenge, Microsoft Fabric's GraphQL API might just be the solution you've been looking for.

Why GraphQL Changes the Game

Think of traditional REST APIs as that over eager friend who tells you their entire life story when you just asked how their day went. You get everything-all the fields, all the data whether you need it or not. Then you're stuck filtering through the noise to find what you actually wanted.

GraphQL, on the other hand, is like having a conversation with someone who listens. You ask for exactly what you need, and that's precisely what you get. Need just customer names and sales amounts? That's all you receive. Want to combine data from multiple related tables? One elegant query handles it all.

Here's what makes GraphQL particularly powerful for Fabric:

  • Precision: Request only the columns you need, nothing more

  • Efficiency: Combine multiple data requests into a single call

  • Flexibility: Query related data in nested structures that mirror real relationships

  • Performance: Reduce network overhead and eliminate over-fetching

Data Path for GraphQL

A GraphQL API operates as a server that sits a top an HTTP server, making an API available for code interaction.

  • Centralized Data Access: The GraphQL server contains code capable of communicating with various data sources.

  • JSON-Based Communication: Send a JSON document to the GraphQL server, containing security tokens and data requests. The server processes this, retrieves data from the underlying sources, and returns another JSON document containing the requested data, messages, and error codes all at once.

  • Schema Definition: GraphQL employs a schema, very similar to a SQL schema with the exception it's over all kinds of data,which defines the structure of available fields and data types, ensuring consistent data access across disparate sources.

  • Operations: GraphQL utilizes specific operation types:

    • Queries: For retrieving data, akin to SQL SELECT statements.

    • Mutations: For changing data (insert, update, delete).

    • Subscriptions: To "subscribe to data as it changes," enabling real-time updates.

Query the data with API for GraphQL

First we will focus on creating GraphQL resource and GraphQL endpoint inside Microsoft Fabric.

  • Go to the Microsoft Fabric workspace and select ā€œNewā€, then choose ā€œGraphQL APIā€ to open the creation wizard.Enter a name and description for the GraphQL.

  • Click ā€œAdd a data sourceā€, choose Warehouse as the source type, and select the target warehouse from the list.Click Connect to proceed to the screen for selecting tables .

  • Select the required tables or views and click Load to include them in the GraphQL API.

šŸ’”
I used the classic ā€˜Northwind dataset’ as my source to load into Warehouse as tables.In the left schema explorer pane shows the tables loaded.Before ran a query a relationship was built between ā€˜fact_sale’ and ā€˜dimension_customer’ table.

Then GraphQL query was created which fetches the first 10 sales records from the fact_sales table and retrieves customer details by traversing the relationship to the dimension_customer table.(This is a sample query to display the capability of nested structure of ā€˜json’ like format in GraphQL syntax.Fabric supports auto complete when coding inside the query pane which makes life much easy for the user.

In the results section it retrieves 10 sales transactions,and for each transaction, include related customer information in nested format.

So far so good.Now, let’s assume we need to retrieve the above results externally from an application. How can we achieve that? Let’s start the journey.

The easiest starting point is to capture the code generated through the toolbar.As of today, the generated code comes in two flavours. In this demo I am using ā€˜Python’ as my code flavour. Set the code aside for now; we'll return to it shortly.

Bringing It to External Applications

Now comes the interesting part: accessing this data from external applications. This is where many implementations fall short, but with proper setup, it becomes surprisingly straightforward.

An ā€˜App registration’ is needed first.I would not into details of creating ā€˜App registration’ as it is more straight forward.

We need give required permissions to ā€˜App Registration’ as below.

Then under Microsoft API’s select ā€˜PowerBI service’ and select as follows.

Then In the Manage > Authentication section, click on Redirect URI configuration

Here in the below ā€˜Redirect URI’ first I tested this in localhost:5500 and later I hosted the project in the link ā€˜https://nalakan.github.io/-fabric-graphql-spa/’ with additional components.

Base code which I copied from GraphQL ā€˜Generated code’ displays below.

Here, you can observe that the GraphQL endpoint on line 23, along with the query(Line 24 -46) used in the Fabric interface, is being passed here.

šŸ’”
You can see that the terminal output matches exactly with the previous instance when we executed it inside Fabric, even when running the same code locally in VS Code.

šŸš€ Project : GraphQL Playground

Rather than stopping at basic functionality, I decided to build something more comprehensive. The result is a full-featured GraphQL playground that extends the Fabric experience for external users.

Key Features

  • Enhanced UI Integration: The interface feels familiar to anyone who's used the Fabric GraphQL explorer, but with additional functionality tailored for external access.

  • Complete Schema Exploration: Users can browse the full schema and understand table relationships without needing access to the Fabric workspace itself.

  • Direct Data Export: One of the most requested features-the ability to download query results directly to local files in various formats.

  • Interactive Query Building: The playground provides real-time query validation and auto-completion, making it accessible to users with varying GraphQL experience levels.

  • Comprehensive Documentation: Built-in docs and schema visualization help users understand data structures and build effective queries.

Application Components

The application structure follows clean architecture principles, with the ā€˜App registration’ details from our earlier setup included in the app.js file. This security model leverages the ā€˜App Registration’ we created earlier, ensuring that only authorized users can access your Fabric data while maintaining proper security standards.

The project is fully functional and available at: https://nalakan.github.io/-fabric-graphql-spa/

The complete source code is available on GitHub: https://github.com/nalakan/-fabric-graphql-spa

Here’s a quick sneak peek šŸ‘€.

Click on the image/gif for zoom

Looking Forward

GraphQL's integration with Microsoft Fabric opens up exciting possibilities for data access patterns. As organizations increasingly need to share data across diverse applications and teams, having a flexible, secure, and performant API layer becomes crucial.

The playground project I've shared represents just the beginning. The same patterns can be extended to build custom dashboards, integrate with external analytics tools, or power mobile applications—all while maintaining the security and governance that enterprise data requires.

Further Reading

For extra details about Fabric's GraphQL, I recommend checking out this nice guide:

https://data-mozart.com/microsoft-fabric-api-for-graphql-everything-you-need-to-know/


Thanks for reading ! I'm always exploring new ways to work with Microsoft Fabric and AI .Stay tuned for more technical walkthroughs and practical implementations.

0
Subscribe to my newsletter

Read articles from Nalaka Wanniarachchi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Nalaka Wanniarachchi
Nalaka Wanniarachchi

Nalaka Wanniarachchi is an accomplished data analytics and data engineering professional with over 20 years of working experience. As a CIMA(ACMA/CGMA) UK qualified ex-banker with strong analytical skills, he transitioned into building robust data solutions. Nalaka specializes in Microsoft Fabric and Power BI, delivering advanced analytics and engineering solutions. He holds a Microsoft certification as a Fabric Analytic Engineer and Power BI Professional, combining technical expertise with a deep understanding of financial and business analytics.