UNPKG

@goteborgco/open-api-js-client

Version:

Official JavaScript client for the Göteborg & Co GraphQL API

30 lines (29 loc) 1.01 kB
import { DocumentNode } from 'graphql'; /** * HTTP client for making GraphQL API requests * * This class handles the low-level HTTP communication with the GraphQL API, * including authentication, request formatting, and error handling. */ export declare class Client { private client; /** * Initialize the HTTP client * * @param apiUrl The base URL for the GraphQL API * @param subscriptionKey Your API subscription key */ constructor(apiUrl: string, subscriptionKey: string); /** * Execute a GraphQL query * * @param query The GraphQL query to execute * @returns The query results from the 'data' field of the GraphQL response * @throws Error When: * - JSON encoding/decoding fails * - HTTP request fails (non-200 status) * - GraphQL response contains errors * - Network or other errors occur */ execute<T = any>(query: string | DocumentNode): Promise<T>; }