@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.
37 lines (36 loc) • 1.47 kB
TypeScript
import { GraphQLSchema } from 'graphql';
export type LaboratoryActivePanel = 'collections' | 'history' | 'docs' | 'tests' | 'settings' | null;
/**
* Targets are held by name rather than by schema object: a poll or an endpoint
* switch replaces every type instance, and a stack of stale references would
* keep rendering a schema the user is no longer looking at.
*/
export type LaboratoryDocsTarget = {
kind: 'type';
name: string;
} | {
kind: 'field';
typeName: string;
fieldName: string;
};
/**
* Builder rows identify a field by its dotted path from an operation root
* (`query.me.id`), which carries no parent type. Walking it back to one is what
* lets a row open the field it actually represents rather than its return type.
*/
export declare const docsTargetFromPath: (path: string[], schema: GraphQLSchema | null) => LaboratoryDocsTarget | null;
export interface LaboratoryDocsState {
activePanel: LaboratoryActivePanel;
/** Empty means the root view listing the operation types. */
docsNavStack: LaboratoryDocsTarget[];
}
export interface LaboratoryDocsActions {
setActivePanel: (panel: LaboratoryActivePanel) => void;
openDocs: (target?: LaboratoryDocsTarget) => void;
pushDocs: (target: LaboratoryDocsTarget) => void;
popDocs: () => void;
resetDocs: () => void;
}
export declare const useDocs: (props: {
defaultActivePanel?: LaboratoryActivePanel;
}) => LaboratoryDocsState & LaboratoryDocsActions;