export type GetApiApiGraphqlSubscribeOptions = {baseUrl: string, AuthenticationToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * GraphQL API over websocket. * * GET /api/graphqlSubscribe * * Also accepts auth: DEPRECATED - API Key, API Key, Basic Auth */ export const getApiApiGraphqlSubscribe = async (options: GetApiApiGraphqlSubscribeOptions) => { const {baseUrl, fetch: fetchFn = fetch, AuthenticationToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (AuthenticationToken !== undefined) headers.set("X-PL-AUTH", AuthenticationToken) const url = `${baseUrl.replace(/\/+$/, '')}/api/graphqlSubscribe${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };