import { useCustom, useApiUrl } from "@refinedev/core";
const apiUrl = useApiUrl();
const { data, isLoading, error } = useCustom({
url: `${apiUrl}/graphql-endpoint`, // Replace with your GraphQL endpoint
method: "post", // GraphQL queries are typically sent as POST requests
config: {
headers: {
"Content-Type": "application/json",
"x-custom-header": "foo-bar", // Add any custom headers if needed
},
body: JSON.stringify({
query: `
query {
users {
id
name
email
}
}
`,
}),
},
});
console.log('Data:', data);
console.log('Error:', error);
console.log('Is Loading:', isLoading);
import { useCustom, useApiUrl } from "@refinedev/core";
const apiUrl = useApiUrl();
const { data, isLoading, error } = useCustom({
url: `${apiUrl}/graphql-endpoint`, // Replace with your GraphQL endpoint
method: "post", // GraphQL queries are typically sent as POST requests
config: {
headers: {
"Content-Type": "application/json",
"x-custom-header": "foo-bar", // Add any custom headers if needed
},
body: JSON.stringify({
query: `
query {
users {
id
name
email
}
}
`,
}),
},
});
console.log('Data:', data);
console.log('Error:', error);
console.log('Is Loading:', isLoading);