Executes a GraphQL query with authentication and error handling
Makes a POST request to a GraphQL endpoint with bearer token authentication. Handles errors and returns the response data or error object.
The GraphQL query string
Promise resolving to response data or error
const data = await fetchGraphQL({ query: ` query GetUser($id: ID!) { user(id: $id) { name email } } `, url: 'https://api.example.com/graphql', token: 'your-bearer-token', variables: { id: '123' }}); Copy
const data = await fetchGraphQL({ query: ` query GetUser($id: ID!) { user(id: $id) { name email } } `, url: 'https://api.example.com/graphql', token: 'your-bearer-token', variables: { id: '123' }});
Executes a GraphQL query with authentication and error handling
Makes a POST request to a GraphQL endpoint with bearer token authentication. Handles errors and returns the response data or error object.