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
GraphQL has changed the way developers interact with data using APIs by offering a more flexible and efficient alternative to REST. Before getting started, Create an API for GraphQL in Fabric and add data to use GraphQL in Fabric.
At the heart of GraphQL are two core operations: queries and mutations. While they may look similar on the surface, they serve very different purposes.
Query_explorer_for_API_for_Graphql
A query is used to fetch data from a data source using API for GraphQL. Think of it like reading information from a database. Queries are read-only operations, meaning they do not modify any data on the server.
Example:
query {
user(id: "1")
{
name
email
}
}
This query asks for the name and email of the user with ID 1. The server responds with nothing more, nothing less.
A mutation is used to modify data on the data source. This includes creating, updating, or deleting records. Mutations are write operations and can change the state of the system.
Example:
mutation {
updateUser(id: "1", input: {name: "Jane Doe"})
{
id
name
}
}
This mutation updates the name of the user with ID 1 to "Jane Doe" and returns the updated user data.
| Feature | Query | Mutation |
| Purpose | Read data | Modify data |
| Server Impact | No change | Changes server state |
| Idempotency | Yes | Not guaranteed |
| Example scenario | Get user profiles | Update a user profile |
Understanding the difference between queries and mutations is essential for building efficient and predictable GraphQL APIs. Queries are your go-to for fetching data, while mutations are your tool for making changes. Keeping these roles clear helps maintain clean, maintainable, and performant applications.
Currently, the following supported data sources can be exposed through the Fabric API for GraphQL:
The enable/disable feature for queries and mutations allows dynamic control over API access, enabling you to activate or deactivate specific operations without modifying code or deploying changes.
Screenshot_of_disable_query_or_mutation_option_shown_on_schema_explorer
Screenshot_of_enable_query_or_mutation_option_shown_on_schema_explorer
Please note that queries or mutations auto generated from stored procedures can only be deleted. Once deleted, they can be re-added using Get Data or the Update Schema options.
In summary, leveraging API for GraphQL through Fabric offers a compelling approach to modern API development. By combining the efficiency and adaptability of GraphQL with Fabric's robust tools, developers can create scalable, precise, and user-focused integrations.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.