piral-urql
Version:
Plugin for providing a GraphQL client in Piral.
35 lines (34 loc) • 943 B
TypeScript
import { UrqlClient } from './types';
export interface GqlConfig {
/**
* Sets the default request init settings.
*/
default?: RequestInit;
/**
* Sets the URL of the GraphQL endpoint.
* @default location.origin
*/
url?: string;
/**
* Sets the URL for the GraphQL subscription endpoint.
*/
subscriptionUrl?: false | string;
/**
* Sets if the subscription should be lazy initialized.
*/
lazy?: boolean;
/**
* Optional callback to the be used in case of a connection.
*/
onConnected?(): void;
/**
* Optional callbsack to be used in case of a disconnect.
* @param err The connection error.
*/
onDisconnected?(err: Array<Error>): void;
}
/**
* Sets up an urql client by using the given config.
* @param config The configuration for the new urql client.
*/
export declare function setupGqlClient(config?: GqlConfig): UrqlClient;