import { createDataProvider } from "@refinedev/graphql";
import { Client } from "@urql/core";
const client = new Client({
url: "YOUR_GRAPHQL_ENDPOINT",
// other client options
});
const dataProvider = createDataProvider(client, {
getList: {
dataMapper: (response, params) => {
// Extract data from your custom schema structure
// where data is at resource.getAll
const resourceName = params.resource;
return response.data?.[resourceName]?.getAll || [];
},
getTotalCount: (response, params) => {
// If you have a way to get total count, implement it here
// Otherwise, return the length of the array
const resourceName = params.resource;
return response.data?.[resourceName]?.getAll?.length || 0;
},
// You may need to customize how variables are built for pagination
buildPagination: (params) => {
const { current = 1, pageSize = 10 } = params.pagination ?? {};
return {
perPage: pageSize,
page: current,
};
}
}
// Add other customizations for create, update, etc. as needed
});
import { createDataProvider } from "@refinedev/graphql";
import { Client } from "@urql/core";
const client = new Client({
url: "YOUR_GRAPHQL_ENDPOINT",
// other client options
});
const dataProvider = createDataProvider(client, {
getList: {
dataMapper: (response, params) => {
// Extract data from your custom schema structure
// where data is at resource.getAll
const resourceName = params.resource;
return response.data?.[resourceName]?.getAll || [];
},
getTotalCount: (response, params) => {
// If you have a way to get total count, implement it here
// Otherwise, return the length of the array
const resourceName = params.resource;
return response.data?.[resourceName]?.getAll?.length || 0;
},
// You may need to customize how variables are built for pagination
buildPagination: (params) => {
const { current = 1, pageSize = 10 } = params.pagination ?? {};
return {
perPage: pageSize,
page: current,
};
}
}
// Add other customizations for create, update, etc. as needed
});