@graphql-hive/laboratory
Version:
[Hive](https://the-guild.dev/graphql/hive) is a fully open-source schema registry, analytics, metrics and gateway for [GraphQL federation](https://the-guild.dev/graphql/hive/federation) and other GraphQL APIs.
42 lines (41 loc) • 2.01 kB
TypeScript
import { GraphQLSchema, IntrospectionQuery } from 'graphql';
import { DebouncedFunc } from 'lodash';
import { LaboratoryEnv, LaboratoryEnvActions, LaboratoryEnvState } from './env';
import { LaboratoryOperationsActions, LaboratoryOperationsState } from './operations';
import { LaboratoryPluginsActions, LaboratoryPluginsState } from './plugins';
import { LaboratoryPreflightActions, LaboratoryPreflightState } from './preflight';
import { LaboratorySettingsActions, LaboratorySettingsState } from './settings';
export interface LaboratoryEndpointState {
endpoint: string | null;
schema: GraphQLSchema | null;
introspection: IntrospectionQuery | null;
defaultEndpoint: string | null;
canIntrospect: boolean;
shouldPollSchema: boolean;
isFetchingSchema: boolean;
}
export type FetchSchemaOptions = {
env?: LaboratoryEnv;
pluginsState?: Record<string, any>;
/** Introspect over the network even when a default introspection is available. */
force?: boolean;
};
export type FetchSchema = DebouncedFunc<(signal?: AbortSignal, options?: FetchSchemaOptions) => Promise<void>>;
export interface LaboratoryEndpointActions {
setEndpoint: (endpoint: string) => void;
fetchSchema: FetchSchema;
reloadSchema: () => void;
restoreDefaultEndpoint: () => void;
}
export declare const EXPECTED_ERROR_REASON = "Expected error reason";
export declare const useEndpoint: (props: {
defaultEndpoint?: string | null;
onEndpointChange?: (endpoint: string | null) => void;
defaultSchemaIntrospection?: IntrospectionQuery | null;
enableDocs?: boolean;
settingsApi?: LaboratorySettingsState & LaboratorySettingsActions;
operationsApi?: LaboratoryOperationsState & LaboratoryOperationsActions;
envApi?: LaboratoryEnvState & LaboratoryEnvActions;
pluginsApi?: LaboratoryPluginsState & LaboratoryPluginsActions;
preflightApi?: LaboratoryPreflightState & LaboratoryPreflightActions;
}) => LaboratoryEndpointState & LaboratoryEndpointActions;