UNPKG

6.58 kBTypeScriptView Raw
1import React, { PropsWithChildren, Component, FunctionComponent } from 'react';
2import { GraphQLSchema, OperationDefinitionNode, GraphQLType, ValidationRule, FragmentDefinitionNode, DocumentNode } from 'graphql';
3import { ToolbarButton } from './ToolbarButton';
4import { ToolbarGroup } from './ToolbarGroup';
5import { ToolbarMenu } from './ToolbarMenu';
6import { QueryEditor } from './QueryEditor';
7import { VariableEditor } from './VariableEditor';
8import { HeaderEditor } from './HeaderEditor';
9import { ResultViewer } from './ResultViewer';
10import { DocExplorer } from './DocExplorer';
11import { QueryHistory } from './QueryHistory';
12import CodeMirrorSizer from '../utility/CodeMirrorSizer';
13import StorageAPI, { Storage } from '../utility/StorageAPI';
14import { VariableToType } from '../utility/getQueryFacts';
15import { GetDefaultFieldNamesFn } from '../utility/fillLeafs';
16import type { Fetcher, Unsubscribable } from '@graphiql/toolkit';
17export declare type Maybe<T> = T | null | undefined;
18export declare type GraphiQLToolbarConfig = {
19 additionalContent?: React.ReactNode;
20};
21export declare type GraphiQLProps = {
22 fetcher: Fetcher;
23 schema?: GraphQLSchema;
24 validationRules?: ValidationRule[];
25 query?: string;
26 variables?: string;
27 headers?: string;
28 operationName?: string;
29 response?: string;
30 storage?: Storage;
31 defaultQuery?: string;
32 defaultVariableEditorOpen?: boolean;
33 defaultSecondaryEditorOpen?: boolean;
34 headerEditorEnabled?: boolean;
35 shouldPersistHeaders?: boolean;
36 externalFragments?: string | FragmentDefinitionNode[];
37 onCopyQuery?: (query?: string) => void;
38 onEditQuery?: (query?: string, documentAST?: DocumentNode) => void;
39 onEditVariables?: (value: string) => void;
40 onEditHeaders?: (value: string) => void;
41 onEditOperationName?: (operationName: string) => void;
42 onToggleDocs?: (docExplorerOpen: boolean) => void;
43 getDefaultFieldNames?: GetDefaultFieldNamesFn;
44 editorTheme?: string;
45 onToggleHistory?: (historyPaneOpen: boolean) => void;
46 ResultsTooltip?: typeof Component | FunctionComponent;
47 readOnly?: boolean;
48 docExplorerOpen?: boolean;
49 toolbar?: GraphiQLToolbarConfig;
50};
51export declare type GraphiQLState = {
52 schema?: GraphQLSchema;
53 query?: string;
54 variables?: string;
55 headers?: string;
56 operationName?: string;
57 docExplorerOpen: boolean;
58 response?: string;
59 editorFlex: number;
60 secondaryEditorOpen: boolean;
61 secondaryEditorHeight: number;
62 variableEditorActive: boolean;
63 headerEditorActive: boolean;
64 headerEditorEnabled: boolean;
65 shouldPersistHeaders: boolean;
66 historyPaneOpen: boolean;
67 docExplorerWidth: number;
68 isWaitingForResponse: boolean;
69 subscription?: Unsubscribable | null;
70 variableToType?: VariableToType;
71 operations?: OperationDefinitionNode[];
72 documentAST?: DocumentNode;
73};
74export declare class GraphiQL extends React.Component<GraphiQLProps, GraphiQLState> {
75 static formatResult(result: any): string;
76 static formatError(rawError: Error): string;
77 _editorQueryID: number;
78 _storage: StorageAPI;
79 codeMirrorSizer: CodeMirrorSizer;
80 componentIsMounted: boolean;
81 docExplorerComponent: Maybe<DocExplorer>;
82 graphiqlContainer: Maybe<HTMLDivElement>;
83 resultComponent: Maybe<ResultViewer>;
84 variableEditorComponent: Maybe<VariableEditor>;
85 headerEditorComponent: Maybe<HeaderEditor>;
86 _queryHistory: Maybe<QueryHistory>;
87 editorBarComponent: Maybe<HTMLDivElement>;
88 queryEditorComponent: Maybe<QueryEditor>;
89 resultViewerElement: Maybe<HTMLElement>;
90 constructor(props: GraphiQLProps);
91 componentDidMount(): void;
92 UNSAFE_componentWillMount(): void;
93 UNSAFE_componentWillReceiveProps(nextProps: GraphiQLProps): void;
94 componentDidUpdate(): void;
95 safeSetState: (nextState: any, callback?: any) => void;
96 render(): JSX.Element;
97 static Logo: typeof GraphiQLLogo;
98 static Toolbar: typeof GraphiQLToolbar;
99 static Footer: typeof GraphiQLFooter;
100 static QueryEditor: typeof QueryEditor;
101 static VariableEditor: typeof VariableEditor;
102 static HeaderEditor: typeof HeaderEditor;
103 static ResultViewer: typeof ResultViewer;
104 static Button: typeof ToolbarButton;
105 static ToolbarButton: typeof ToolbarButton;
106 static Group: typeof ToolbarGroup;
107 static Menu: typeof ToolbarMenu;
108 static MenuItem: React.FC<{
109 onSelect: () => void;
110 title: string;
111 label: string;
112 }>;
113 getQueryEditor(): import("codemirror").Editor | undefined;
114 getVariableEditor(): import("codemirror").Editor | null;
115 getHeaderEditor(): import("codemirror").Editor | null;
116 refresh(): void;
117 autoCompleteLeafs(): string | undefined;
118 private fetchSchema;
119 private _fetchQuery;
120 handleClickReference: (reference: GraphQLType) => void;
121 handleRunQuery: (selectedOperationName?: string | undefined) => Promise<void>;
122 handleStopQuery: () => void;
123 private _runQueryAtCursor;
124 handlePrettifyQuery: () => void;
125 handleMergeQuery: () => void;
126 handleEditQuery: (this: any, value: string) => void;
127 handleCopyQuery: () => void;
128 private _updateQueryFacts;
129 handleEditVariables: (value: string) => void;
130 handleEditHeaders: (value: string) => void;
131 handleEditOperationName: (operationName: string) => void;
132 handleHintInformationRender: (elem: HTMLDivElement) => void;
133 handleEditorRunQuery: () => void;
134 private _onClickHintInformation;
135 handleToggleDocs: () => void;
136 handleToggleHistory: () => void;
137 handleSelectHistoryQuery: (query?: string | undefined, variables?: string | undefined, headers?: string | undefined, operationName?: string | undefined) => void;
138 private handleResizeStart;
139 handleResetResize: () => void;
140 private _didClickDragBar;
141 private handleDocsResizeStart;
142 private handleDocsResetResize;
143 private handleTabClickPropogation;
144 private handleOpenHeaderEditorTab;
145 private handleOpenVariableEditorTab;
146 private handleSecondaryEditorResizeStart;
147}
148declare function GraphiQLLogo<TProps>(props: PropsWithChildren<TProps>): JSX.Element;
149declare namespace GraphiQLLogo {
150 var displayName: string;
151}
152declare function GraphiQLToolbar<TProps>(props: PropsWithChildren<TProps>): JSX.Element;
153declare namespace GraphiQLToolbar {
154 var displayName: string;
155}
156declare function GraphiQLFooter<TProps>(props: PropsWithChildren<TProps>): JSX.Element;
157declare namespace GraphiQLFooter {
158 var displayName: string;
159}
160export {};
161//# sourceMappingURL=GraphiQL.d.ts.map
\No newline at end of file