Forum Discussion
Fabric GraphQL Pagination
- Anonymous1 year ago
Hi nbj-ksdh ,
Thank you for reaching out to Microsoft Fabric Community Forum!We sincerely apologize for the delay in response.Seems your issue is not resolved. Therefore, we request you to consider raising a support ticket to resolve the issue.
To raise a support ticket for Fabric and Power BI, kindly follow the steps outlined in the following guide:
How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn
If this post helps, please give us Kudos and consider marking it Accept as solution to assist other members in finding it more easily.
Hello nbj-ksdh
Please give this a try
const fetch = require('node-fetch');
// Example function to retrieve large sets in 1,000-row chunks.
async function fetchAllRows() {
let offset = 0;
const limit = 1000;
let allRows = [];
while (true) {
// Adjust field names or parameters as needed for your schema.
const query = `
query GetRows($limit: Int!, $offset: Int!) {
myTable(limit: $limit, offset: $offset) {
id
name
// Include other columns as necessary
}
}
`;
const response = await fetch("YOUR_GRAPHQL_ENDPOINT", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ query, variables: { limit, offset } })
});
const json = await response.json();
const currentBatch = json.data?.myTable || [];
allRows.push(...currentBatch);
// If there's fewer than 'limit' rows, we're done
if (currentBatch.length < limit) {
break;
}
offset += limit;
}
return allRows;
}
// Usage example:
fetchAllRows()
.then(rows => {
console.log(`Retrieved ${rows.length} total rows.`);
// Do something with your data here
})
.catch(err => console.error(err));
function uses offset-based pagination (`limit` and `offset`), which is compatible with GraphQL implementations in Microsoft Fabric. However, if the schema includes fields like `endCursor` and `hasNextPage`, you might consider switching to cursor-based pagination for better efficiency
You must create a GraphQL API endpoint within your Fabric workspace. This involves selecting a data source (e.g., a Data Warehouse or SQL database) and exposing the required tables or fields through the API. The schema is automatically generated based on the selected data source
Please accept the answer if this is helpful and give kudos
nilendraFabric looks like you just pasted my request into ChatGPT and copied the answer here. If you have worked just a little with GraphQL in Fabric, you'd know that 'limit' and 'offset' aren't part of the schema...
- nilendraFabric1 year agoSuper User
Apologies nbj-ksdh
I haven't used chatgpt as such , but yes haven't researched properly.
You are correct here ,to implement pagination in Microsoft Fabric’s GraphQL API, you must use cursor-based pagination, as the schema does not support `limit` and `offset` parameters.