UMD Web Utilities Library
    Preparing search index...

    Function fetchGraphQL

    • 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.

      Parameters

      • query: { query: string; token: string; url: string; variables?: GraphQLVariables }

        The GraphQL query string

      Returns Promise<any>

      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' }
      });