UNPKG

6.03 kBTypeScriptView Raw
1import React, { PropsWithChildren, ReactNode } from 'react';
2import { GraphQLSchema, ValidationRule, FragmentDefinitionNode, DocumentNode, IntrospectionQuery } from 'graphql';
3import { ExecutionContextType, useDragResize } from '@graphiql/react';
4import type { EditorContextType, ExplorerContextType, HistoryContextType, ResponseTooltipType, SchemaContextType, StorageContextType, TabsState, KeyMap } from '@graphiql/react';
5import { ToolbarButton } from './ToolbarButton';
6import { ToolbarGroup } from './ToolbarGroup';
7import { ToolbarMenu } from './ToolbarMenu';
8import { QueryEditor } from './QueryEditor';
9import { VariableEditor } from './VariableEditor';
10import { HeaderEditor } from './HeaderEditor';
11import { ResultViewer } from './ResultViewer';
12import type { Fetcher, GetDefaultFieldNamesFn } from '@graphiql/toolkit';
13export declare type GraphiQLToolbarConfig = {
14 additionalContent?: React.ReactNode;
15};
16export declare type GraphiQLProps = {
17 fetcher: Fetcher;
18 schema?: GraphQLSchema | IntrospectionQuery | null;
19 validationRules?: ValidationRule[];
20 query?: string;
21 variables?: string;
22 headers?: string;
23 operationName?: string;
24 response?: string;
25 storage?: Storage;
26 defaultQuery?: string;
27 defaultVariableEditorOpen?: boolean;
28 defaultSecondaryEditorOpen?: boolean;
29 headerEditorEnabled?: boolean;
30 shouldPersistHeaders?: boolean;
31 externalFragments?: string | FragmentDefinitionNode[];
32 onCopyQuery?: (query?: string) => void;
33 onEditQuery?: (query?: string, documentAST?: DocumentNode) => void;
34 onEditVariables?: (value: string) => void;
35 onEditHeaders?: (value: string) => void;
36 onEditOperationName?: (operationName: string) => void;
37 onToggleDocs?: (docExplorerOpen: boolean) => void;
38 getDefaultFieldNames?: GetDefaultFieldNamesFn;
39 editorTheme?: string;
40 keyMap?: KeyMap;
41 onToggleHistory?: (historyPaneOpen: boolean) => void;
42 ResultsTooltip?: ResponseTooltipType;
43 dangerouslyAssumeSchemaIsValid?: boolean;
44 inputValueDeprecation?: boolean;
45 schemaDescription?: boolean;
46 introspectionQueryName?: string;
47 readOnly?: boolean;
48 docExplorerOpen?: boolean;
49 toolbar?: GraphiQLToolbarConfig;
50 maxHistoryLength?: number;
51 onSchemaChange?: (schema: GraphQLSchema) => void;
52 beforeTopBarContent?: React.ReactElement | null;
53 tabs?: boolean | {
54 onTabChange?: (tab: TabsState) => void;
55 };
56 children?: ReactNode;
57};
58export declare class GraphiQL extends React.Component<GraphiQLProps> {
59 ref: GraphiQLWithContext | null;
60 constructor(props: GraphiQLProps);
61 componentDidMount(): void;
62 render(): JSX.Element;
63 getQueryEditor(): import("@graphiql/react/types/editor/context").CodeMirrorEditorWithOperationFacts | null;
64 getVariableEditor(): import("@graphiql/react/types/editor/types").CodeMirrorEditor | null;
65 getHeaderEditor(): import("@graphiql/react/types/editor/types").CodeMirrorEditor | null;
66 refresh(): void;
67 autoCompleteLeafs(): string | undefined;
68 static formatResult: (result: any) => string;
69 static formatError: (error: any) => string;
70 static Logo: typeof GraphiQLLogo;
71 static Toolbar: typeof GraphiQLToolbar;
72 static Footer: typeof GraphiQLFooter;
73 static QueryEditor: typeof QueryEditor;
74 static VariableEditor: typeof VariableEditor;
75 static HeaderEditor: typeof HeaderEditor;
76 static ResultViewer: typeof ResultViewer;
77 static Button: typeof ToolbarButton;
78 static ToolbarButton: typeof ToolbarButton;
79 static Group: typeof ToolbarGroup;
80 static Menu: typeof ToolbarMenu;
81 static MenuItem: React.FC<{
82 onSelect: () => void;
83 title: string;
84 label: string;
85 }>;
86}
87declare type GraphiQLWithContextProviderProps = Omit<GraphiQLProps, 'dangerouslyAssumeSchemaIsValid' | 'defaultQuery' | 'docExplorerOpen' | 'externalFragments' | 'fetcher' | 'headers' | 'inputValueDeprecation' | 'introspectionQueryName' | 'maxHistoryLength' | 'onEditOperationName' | 'onSchemaChange' | 'onToggleDocs' | 'onToggleHistory' | 'operationName' | 'query' | 'response' | 'schema' | 'schemaDescription' | 'shouldPersistHeaders' | 'storage' | 'validationRules' | 'variables'>;
88declare type GraphiQLWithContextConsumerProps = Omit<GraphiQLWithContextProviderProps, 'fetcher' | 'getDefaultFieldNames'> & {
89 editorContext: EditorContextType;
90 executionContext: ExecutionContextType;
91 explorerContext: ExplorerContextType | null;
92 historyContext: HistoryContextType | null;
93 schemaContext: SchemaContextType;
94 storageContext: StorageContextType | null;
95 autoCompleteLeafs(): string | undefined;
96 copy(): void;
97 merge(): void;
98 prettify(): void;
99 docResize: ReturnType<typeof useDragResize>;
100 editorResize: ReturnType<typeof useDragResize>;
101 secondaryEditorResize: ReturnType<typeof useDragResize>;
102};
103export declare type GraphiQLState = {
104 activeSecondaryEditor: 'variable' | 'header';
105};
106declare class GraphiQLWithContext extends React.Component<GraphiQLWithContextConsumerProps, GraphiQLState> {
107 constructor(props: GraphiQLWithContextConsumerProps);
108 render(): JSX.Element;
109 getQueryEditor(): import("@graphiql/react/types/editor/context").CodeMirrorEditorWithOperationFacts | null;
110 getVariableEditor(): import("@graphiql/react/types/editor/types").CodeMirrorEditor | null;
111 getHeaderEditor(): import("@graphiql/react/types/editor/types").CodeMirrorEditor | null;
112 refresh(): void;
113 autoCompleteLeafs(): string | undefined;
114}
115declare function GraphiQLLogo<TProps>(props: PropsWithChildren<TProps>): JSX.Element;
116declare namespace GraphiQLLogo {
117 var displayName: string;
118}
119declare function GraphiQLToolbar<TProps>(props: PropsWithChildren<TProps>): JSX.Element;
120declare namespace GraphiQLToolbar {
121 var displayName: string;
122}
123declare function GraphiQLFooter<TProps>(props: PropsWithChildren<TProps>): JSX.Element;
124declare namespace GraphiQLFooter {
125 var displayName: string;
126}
127export {};
128//# sourceMappingURL=GraphiQL.d.ts.map
\No newline at end of file