Options
All
  • Public
  • Public/Protected
  • All
Menu

Package graphiql-react

Changelog | API Docs | NPM

@graphiql/react

A React SDK for building integrated GraphQL developer experiences for the web.

Purpose

This package contains a set of building blocks that allow its users to build GraphQL IDEs with ease. It's the set of components that make up GraphiQL, the first and official GraphQL IDE, owned and maintained by the GraphQL Foundation.

There are two kinds of building blocks that this package provides: Stateful context providers for state management and simple UI components.

Getting started

All the state for your GraphQL IDE lives in multiple contexts. The easiest way to get started is by using the GraphiQLProvider component that renders all the individual providers.

There is one required prop called fetcher. This is a function that performs GraphQL request against a given endpoint. You can easily create a fetcher using the method createGraphiQLFetcher from the @graphiql/toolkit package.

import { GraphiQLProvider } from '@graphiql/react';
import { createGraphiQLFetcher } from '@graphiql/toolkit';

const fetcher = createGraphiQLFetcher({
  url: 'https://my.graphql.api/graphql',
});

function MyGraphQLIDE() {
  return (
    <GraphiQLProvider fetcher={fetcher}>
      <div className="graphiql-container">Hello GraphQL</div>
    </GraphiQLProvider>
  );
}

Inside the provider you can now use any UI component provided by @graphiql/react. For example, you can render a query editor like this:

import { QueryEditor } from '@graphiql/react';

function MyGraphQLIDE() {
  return (
    <GraphiQLProvider fetcher={fetcher}>
      <div className="graphiql-container">
        <QueryEditor />
      </div>
    </GraphiQLProvider>
  );
}

The package also ships the necessary CSS that all its UI components need. You can import them from @graphiql/react/style.css.

Note: In order for these styles to apply, the UI components need to be rendered inside an element that has a class name graphiql-container.

By default, the UI components will try to use the Roboto font for regular text and the Fira Code font for mono-space text. If you want to use the default fonts you can load them using these files:

  • @graphiql/react/font/roboto.css
  • @graphiql/react/font/fira-code.css.

You can of course use any other method to load these fonts (for example loading them from Google Fonts).

Further details on how to use @graphiql/react can be found in the reference implementation of a GraphQL IDE - GraphiQL - in the graphiql package.

Available contexts

There are multiple contexts that own different parts of the state that make up a complete GraphQL IDE. For each context there is a provider component (<name>ContextProvider) that makes sure the context is initialized and managed properly. These components contains all the logic related to state management. In addition, for each context there is also a hook (use<name>Context) that allows you to consume its current value.

Here is a list of all contexts that come with @graphiql/react

  • StorageContext: Provides a storage API that can be used to persist state in the browser (by default using localStorage)
  • EditorContext: Manages all the editors and tabs
  • SchemaContext: Fetches, validates and stores the GraphQL schema
  • ExecutionContext: Executes GraphQL requests
  • HistoryContext: Persists executed requests in storage
  • ExplorerContext: Handles the state for the docs explorer

All context properties are documented using JSDoc comments. If you're using an IDE like VSCode for development these descriptions will show up in auto-complete tooltips. All these descriptions can also be found in the API Docs.

Theming

All the components from @graphiql/react have been designed with customization in mind. We achieve this using CSS variables.

All variables that are available for customization can be found in the root.css file.

Colors

Colors are defined using the HSL format. All CSS variables for colors are defined as a list of the three values that make up HSL (hue, saturation and lightness).

This approach allows @graphiql/react to use transparent colors by passing the value of the CSS variable in the hsla function. This enables us to provide truly reusable UI elements where good contrasts are preserved regardless of the elements background.

Development

If you want to develop with @graphiql/react locally - in particular when working on the graphiql package - all you need to do is run yarn dev in the package folder in a separate terminal. This will build the package using Vite. When using it in combination with yarn dev:graphiql (running in the repo root) this will give you auto-reloading when working on graphiql and @graphiql/react simultaneously.

Index

References

Type aliases

Variables

Functions

Object literals

References

ArgumentIcon

Re-exports ArgumentIcon

Button

Re-exports Button

Button

Re-exports Button

ButtonGroup

Re-exports ButtonGroup

ButtonGroup

Re-exports ButtonGroup

ChevronDownIcon

Re-exports ChevronDownIcon

ChevronLeftIcon

Re-exports ChevronLeftIcon

ChevronUpIcon

Re-exports ChevronUpIcon

CloseIcon

Re-exports CloseIcon

CommonEditorProps

Re-exports CommonEditorProps

CommonEditorProps

Re-exports CommonEditorProps

CopyIcon

Re-exports CopyIcon

DeprecatedArgumentIcon

Re-exports DeprecatedArgumentIcon

DeprecatedEnumValueIcon

Re-exports DeprecatedEnumValueIcon

DeprecatedFieldIcon

Re-exports DeprecatedFieldIcon

Dialog

Re-exports Dialog

Dialog

Re-exports Dialog

DialogRoot

Re-exports DialogRoot

DialogRoot

Re-exports DialogRoot

DirectiveIcon

Re-exports DirectiveIcon

DocsFilledIcon

Re-exports DocsFilledIcon

DocsIcon

Re-exports DocsIcon

DropdownMenu

Re-exports DropdownMenu

DropdownMenu

Re-exports DropdownMenu

EditorContextProvider

Re-exports EditorContextProvider

EditorContextProvider

Re-exports EditorContextProvider

EnumValueIcon

Re-exports EnumValueIcon

ExecuteButton

Re-exports ExecuteButton

ExecuteButton

Re-exports ExecuteButton

ExecutionContextProvider

Re-exports ExecutionContextProvider

ExecutionContextType

Re-exports ExecutionContextType

FieldIcon

Re-exports FieldIcon

GraphiQLPlugin

Re-exports GraphiQLPlugin

GraphiQLProvider

Re-exports GraphiQLProvider

HeaderEditor

Re-exports HeaderEditor

HeaderEditor

Re-exports HeaderEditor

HeaderEditor

Re-exports HeaderEditor

HistoryIcon

Re-exports HistoryIcon

ImagePreview

Re-exports ImagePreview

ImagePreview

Re-exports ImagePreview

ImagePreview

Re-exports ImagePreview

ImplementsIcon

Re-exports ImplementsIcon

KeyMap

Re-exports KeyMap

KeyMap

Re-exports KeyMap

KeyboardShortcutIcon

Re-exports KeyboardShortcutIcon

MagnifyingGlassIcon

Re-exports MagnifyingGlassIcon

MarkdownContent

Re-exports MarkdownContent

MarkdownContent

Re-exports MarkdownContent

MergeIcon

Re-exports MergeIcon

PenIcon

Re-exports PenIcon

PlayIcon

Re-exports PlayIcon

PluginContextProvider

Re-exports PluginContextProvider

PluginContextType

Re-exports PluginContextType

PlusIcon

Re-exports PlusIcon

PrettifyIcon

Re-exports PrettifyIcon

QueryEditor

Re-exports QueryEditor

QueryEditor

Re-exports QueryEditor

QueryEditor

Re-exports QueryEditor

ReloadIcon

Re-exports ReloadIcon

ResponseEditor

Re-exports ResponseEditor

ResponseEditor

Re-exports ResponseEditor

ResponseEditor

Re-exports ResponseEditor

ResponseTooltipType

Re-exports ResponseTooltipType

ResponseTooltipType

Re-exports ResponseTooltipType

RootTypeIcon

Re-exports RootTypeIcon

SchemaContextProvider

Re-exports SchemaContextProvider

SchemaContextType

Re-exports SchemaContextType

SettingsIcon

Re-exports SettingsIcon

Spinner

Re-exports Spinner

Spinner

Re-exports Spinner

StarFilledIcon

Re-exports StarFilledIcon

StarIcon

Re-exports StarIcon

StopIcon

Re-exports StopIcon

StorageContextProvider

Re-exports StorageContextProvider

Tab

Re-exports Tab

Tab

Re-exports Tab

Tabs

Re-exports Tabs

Tabs

Re-exports Tabs

TabsState

Re-exports TabsState

TabsState

Re-exports TabsState

Theme

Re-exports Theme

ToolbarButton

Re-exports ToolbarButton

ToolbarButton

Re-exports ToolbarButton

ToolbarMenu

Re-exports ToolbarMenu

ToolbarMenu

Re-exports ToolbarMenu

Tooltip

Re-exports Tooltip

Tooltip

Re-exports Tooltip

TooltipRoot

Re-exports TooltipRoot

TooltipRoot

Re-exports TooltipRoot

TrashIcon

Re-exports TrashIcon

TypeIcon

Re-exports TypeIcon

UnStyledButton

Re-exports UnStyledButton

UnStyledButton

Re-exports UnStyledButton

UseHeaderEditorArgs

Re-exports UseHeaderEditorArgs

UseHeaderEditorArgs

Re-exports UseHeaderEditorArgs

UseQueryEditorArgs

Re-exports UseQueryEditorArgs

UseQueryEditorArgs

Re-exports UseQueryEditorArgs

UseResponseEditorArgs

Re-exports UseResponseEditorArgs

UseResponseEditorArgs

Re-exports UseResponseEditorArgs

UseVariableEditorArgs

Re-exports UseVariableEditorArgs

UseVariableEditorArgs

Re-exports UseVariableEditorArgs

VariableEditor

Re-exports VariableEditor

VariableEditor

Re-exports VariableEditor

VariableEditor

Re-exports VariableEditor

WriteableEditorProps

Re-exports WriteableEditorProps

WriteableEditorProps

Re-exports WriteableEditorProps

cn

Re-exports cn

createBoundedUseStore

Re-exports createBoundedUseStore

createBoundedUseStore

Re-exports createBoundedUseStore

debounce

Re-exports debounce

debounce

Re-exports debounce

getAutoCompleteLeafs

Re-exports getAutoCompleteLeafs

getAutoCompleteLeafs

Re-exports getAutoCompleteLeafs

isMacOs

Re-exports isMacOs

isMacOs

Re-exports isMacOs

useCopyQuery

Re-exports useCopyQuery

useCopyQuery

Re-exports useCopyQuery

useDragResize

Re-exports useDragResize

useDragResize

Re-exports useDragResize

useEditorState

Re-exports useEditorState

useEditorState

Re-exports useEditorState

useEditorStore

Re-exports useEditorStore

useEditorStore

Re-exports useEditorStore

useExecutionStore

Re-exports useExecutionStore

useHeaderEditor

Re-exports useHeaderEditor

useHeaderEditor

Re-exports useHeaderEditor

useHeadersEditorState

Re-exports useHeadersEditorState

useHeadersEditorState

Re-exports useHeadersEditorState

useMergeQuery

Re-exports useMergeQuery

useMergeQuery

Re-exports useMergeQuery

useOperationsEditorState

Re-exports useOperationsEditorState

useOperationsEditorState

Re-exports useOperationsEditorState

useOptimisticState

Re-exports useOptimisticState

useOptimisticState

Re-exports useOptimisticState

usePluginStore

Re-exports usePluginStore

usePrettifyEditors

Re-exports usePrettifyEditors

usePrettifyEditors

Re-exports usePrettifyEditors

useQueryEditor

Re-exports useQueryEditor

useQueryEditor

Re-exports useQueryEditor

useResponseEditor

Re-exports useResponseEditor

useResponseEditor

Re-exports useResponseEditor

useSchemaStore

Re-exports useSchemaStore

useStorage

Re-exports useStorage

useTheme

Re-exports useTheme

useVariableEditor

Re-exports useVariableEditor

useVariableEditor

Re-exports useVariableEditor

useVariablesEditorState

Re-exports useVariablesEditorState

useVariablesEditorState

Re-exports useVariablesEditorState

Type aliases

CodeMirrorEditor

CodeMirrorEditor: Editor & { options?: any }

CodeMirrorEditorWithOperationFacts

CodeMirrorEditorWithOperationFacts: CodeMirrorEditor & { documentAST: DocumentNode | null; operationName: string | null; operations: OperationDefinitionNode[] | null; variableToType: VariableToType | null }

CodeMirrorType

CodeMirrorType: CodeMirror

CommonEditorProps

CommonEditorProps: { editorTheme?: undefined | string; keyMap?: KeyMap }

Type declaration

ExecutionContextType

ExecutionContextType: { getDefaultFieldNames?: GetDefaultFieldNamesFn; isFetching: boolean; operationName: string | null; queryId: number; subscription: Unsubscribable | null; run: any; stop: any }

Type declaration

  • Optional getDefaultFieldNames?: GetDefaultFieldNamesFn

    A function to determine which field leafs are automatically added when trying to execute a query with missing selection sets. It will be called with the GraphQLType for which fields need to be added.

  • isFetching: boolean

    If there is currently a GraphQL request in-flight. For multipart requests like subscriptions, this will be true while fetching the first partial response and false while fetching subsequent batches.

    default

    false

  • operationName: string | null

    The operation name that will be sent with all GraphQL requests.

    default

    null

  • queryId: number
    default

    0

  • subscription: Unsubscribable | null

    Represents an active GraphQL subscription.

    For multipart operations such as subscriptions, this will hold an Unsubscribable object while the request is in-flight. It remains non-null until the operation completes or is manually unsubscribed.

    remarks

    Use subscription?.unsubscribe() to cancel the request.

    default

    null

  • run: function
    • run(): void
  • stop: function
    • stop(): void

GraphiQLPlugin

GraphiQLPlugin: { content: ComponentType; icon: ComponentType; title: string }

Type declaration

  • content: ComponentType

    A component that renders content into the plugin pane.

  • icon: ComponentType

    A component that renders an icon that will be shown inside a button that toggles the plugin visibility.

  • title: string

    The unique title of the plugin. If two plugins are present with the same title the provider component will throw an error.

KeyMap

KeyMap: "sublime" | "emacs" | "vim"

PluginContextType

PluginContextType: { plugins: GraphiQLPlugin[]; referencePlugin?: GraphiQLPlugin; visiblePlugin: GraphiQLPlugin | null; onTogglePluginVisibility?: any; setVisiblePlugin: any }

Type declaration

  • plugins: GraphiQLPlugin[]

    A list of all current plugins, including the built-in ones (the doc explorer and the history).

  • Optional referencePlugin?: GraphiQLPlugin

    The plugin which is used to display the reference documentation when selecting a type.

  • visiblePlugin: GraphiQLPlugin | null

    The plugin which is currently visible.

  • onTogglePluginVisibility: function
    • onTogglePluginVisibility(visiblePlugin: GraphiQLPlugin | null): void
    • Invoked when the visibility state of any plugin changes.

      Parameters

      • visiblePlugin: GraphiQLPlugin | null

        The plugin object that is now visible. If no plugin is visible, the function will be invoked with null.

      Returns void

  • setVisiblePlugin: function
    • Defines the plugin which is currently visible.

      Parameters

      • plugin: GraphiQLPlugin | string | null

        The plugin that should become visible. You can either pass the plugin object (has to be referentially equal to the one passed as prop) or the plugin title as string. If null is passed, no plugin will be visible.

      Returns void

ResponseTooltipType

ResponseTooltipType: ComponentType<{ pos: Position; token: Token }>

SchemaContextType

SchemaContextType: { fetchError: string | null; isFetching: boolean; requestCounter: number; schema: MaybeGraphQLSchema; schemaReference: SchemaReference | null; setSchemaReference: Dispatch<SchemaReference>; shouldIntrospect: boolean; validationErrors: readonly GraphQLError[]; introspect: any }

Type declaration

  • fetchError: string | null

    Stores an error raised during introspecting or building the GraphQL schema from the introspection result.

  • isFetching: boolean

    If there currently is an introspection request in-flight.

  • requestCounter: number

    A counter that is incremented each time introspection is triggered or the schema state is updated.

  • schema: MaybeGraphQLSchema

    The current GraphQL schema.

  • schemaReference: SchemaReference | null

    The last type selected by the user.

  • setSchemaReference: Dispatch<SchemaReference>

    Set the current selected type.

  • shouldIntrospect: boolean

    false when schema is provided via props as GraphQLSchema | null

  • validationErrors: readonly GraphQLError[]

    A list of errors from validating the current GraphQL schema. The schema is valid if and only if this list is empty.

  • introspect: function
    • introspect(): Promise<void>
    • Trigger building the GraphQL schema. This might trigger an introspection request if no schema is passed via props and if using a schema is not explicitly disabled by passing null as value for the schema prop. If there is a schema (either fetched using introspection or passed via props) it will be validated, unless this is explicitly skipped using the dangerouslyAssumeSchemaIsValid prop.

      Returns Promise<void>

TabDefinition

TabDefinition: { headers?: string | null; query: string | null; variables?: string | null }

Type declaration

  • Optional headers?: string | null

    The contents of the headers editor of this tab.

  • query: string | null

    The contents of the query editor of this tab.

  • Optional variables?: string | null

    The contents of the variable editor of this tab.

TabState

TabState: TabDefinition & { hash: string; id: string; operationName: string | null; response: string | null; title: string }

This object describes the state of a single tab.

TabsState

TabsState: { activeTabIndex: number; tabs: TabState[] }

This object describes the state of all tabs.

Type declaration

  • activeTabIndex: number

    The index of the currently active tab with regards to the tabs list of this object.

  • tabs: TabState[]

    A list of state objects for each tab.

Theme

Theme: "light" | "dark" | null

The value null semantically means that the user does not explicitly choose any theme, so we use the system default.

UseCopyQueryArgs

UseCopyQueryArgs: { caller?: Function; onCopyQuery?: undefined | ((query: string) => void) }

Type declaration

  • Optional caller?: Function

    This is only meant to be used internally in @graphiql/react.

  • Optional onCopyQuery?: undefined | ((query: string) => void)

    Invoked when the current contents of the query editor are copied to the clipboard.

    param

    The content that has been copied.

UseHeaderEditorArgs

UseHeaderEditorArgs: WriteableEditorProps & { onEdit?: any }

UsePrettifyEditorsArgs

UsePrettifyEditorsArgs: { onPrettifyQuery?: undefined | ((query: string) => MaybePromise<string>) }

Type declaration

  • Optional onPrettifyQuery?: undefined | ((query: string) => MaybePromise<string>)

    Invoked when the prettify callback is invoked.

    param

    The current value of the query editor.

    default

    import { parse, print } from 'graphql'

    (query) => print(parse(query))

    returns

    The formatted query.

UseQueryEditorArgs

UseQueryEditorArgs: WriteableEditorProps & Pick<UseCopyQueryArgs, "onCopyQuery"> & Pick<UsePrettifyEditorsArgs, "onPrettifyQuery"> & { onClickReference?: any; onEdit?: any }

UseResponseEditorArgs

UseResponseEditorArgs: CommonEditorProps & { responseTooltip?: ResponseTooltipType }

UseVariableEditorArgs

UseVariableEditorArgs: WriteableEditorProps & { onClickReference?: any; onEdit?: any }

WriteableEditorProps

WriteableEditorProps: CommonEditorProps & { readOnly?: undefined | false | true }

Variables

Const ArgumentIcon

ArgumentIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_ArgumentIcon)

Const Button

Button: ForwardRefExoticComponent<Omit<ButtonProps & ClassAttributes<HTMLButtonElement> & ButtonHTMLAttributes<HTMLButtonElement>, "ref"> & RefAttributes<HTMLButtonElement>> = forwardRef<HTMLButtonElement,ButtonProps & JSX.IntrinsicElements['button']>((props, ref) => (<button{...props}ref={ref}className={clsx('graphiql-button',{success: 'graphiql-button-success',error: 'graphiql-button-error',}[props.state!],props.className,)}/>))

Const ButtonGroup

ButtonGroup: ForwardRefExoticComponent<Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & RefAttributes<HTMLDivElement>> = forwardRef<HTMLDivElement,JSX.IntrinsicElements['div']>((props, ref) => (<div{...props}ref={ref}className={clsx('graphiql-button-group', props.className)}/>))

Const ChevronDownIcon

ChevronDownIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_ChevronDownIcon)

Const ChevronLeftIcon

ChevronLeftIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_ChevronLeftIcon)

Const ChevronUpIcon

ChevronUpIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_ChevronUpIcon)

Const CloseIcon

CloseIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_CloseIcon)

Const CopyIcon

CopyIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_CopyIcon)

Const DEFAULT_EDITOR_THEME

DEFAULT_EDITOR_THEME: "graphiql" = "graphiql"

Const DEFAULT_KEY_MAP

DEFAULT_KEY_MAP: KeyMap = "sublime"

Const DEFAULT_QUERY

DEFAULT_QUERY: "# Welcome to GraphiQL## GraphiQL is an in-browser tool for writing, validating, and# testing GraphQL queries.## Type queries into this side of the screen, and you will see intelligent# typeaheads aware of the current GraphQL type schema and live syntax and# validation errors highlighted within the text.## GraphQL queries typically start with a "{" character. Lines that start# with a # are ignored.## An example GraphQL query might look like:## {# field(arg: "value") {# subField# }# }## Keyboard shortcuts:## Prettify query: Shift-Ctrl-P (or press the prettify button)## Merge fragments: Shift-Ctrl-M (or press the merge button)## Run Query: Ctrl-Enter (or press the play button)## Auto Complete: Ctrl-Space (or just start typing)#" = `# Welcome to GraphiQL## GraphiQL is an in-browser tool for writing, validating, and# testing GraphQL queries.## Type queries into this side of the screen, and you will see intelligent# typeaheads aware of the current GraphQL type schema and live syntax and# validation errors highlighted within the text.## GraphQL queries typically start with a "{" character. Lines that start# with a # are ignored.## An example GraphQL query might look like:## {# field(arg: "value") {# subField# }# }## Keyboard shortcuts:## Prettify query: Shift-Ctrl-P (or press the prettify button)## Merge fragments: Shift-Ctrl-M (or press the merge button)## Run Query: Ctrl-Enter (or press the play button)## Auto Complete: Ctrl-Space (or just start typing)#`

Const DeprecatedArgumentIcon

DeprecatedArgumentIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_DeprecatedArgumentIcon)

Const DeprecatedEnumValueIcon

DeprecatedEnumValueIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_DeprecatedEnumValueIcon)

Const DeprecatedFieldIcon

DeprecatedFieldIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_DeprecatedFieldIcon)

Const Dialog

Dialog: FC<DialogProps> & { Close: ForwardRefExoticComponent<Omit<DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & RefAttributes<HTMLButtonElement>>; Description: ForwardRefExoticComponent<DialogDescriptionProps & RefAttributes<HTMLParagraphElement>>; Title: ForwardRefExoticComponent<DialogTitleProps & RefAttributes<HTMLHeadingElement>>; Trigger: ForwardRefExoticComponent<DialogTriggerProps & RefAttributes<HTMLButtonElement>> } = Object.assign(DialogRoot, {Close: DialogClose,Title: D.Title,Trigger: D.Trigger,Description: D.Description,})

Const DirectiveIcon

DirectiveIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_DirectiveIcon)

Const DocsFilledIcon

DocsFilledIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_DocsFilledIcon)

Const DocsIcon

DocsIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_DocsIcon)

Const DropdownMenu

DropdownMenu: FC<DropdownMenuProps> & { Button: ForwardRefExoticComponent<Omit<DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & RefAttributes<HTMLButtonElement>>; Content: FC<DropdownMenuContentProps>; Item: FC<DropdownMenuItemProps> } = Object.assign(Root, {Button,Item,Content,})

Const EnumValueIcon

EnumValueIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_EnumValueIcon)

Const FieldIcon

FieldIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_FieldIcon)

Const HistoryIcon

HistoryIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_HistoryIcon)

Const ImagePreview

ImagePreview: FC<ImagePreviewProps> & { shouldRender: any } = Object.assign(ImagePreview_, {shouldRender(token: Token) {const url = tokenToURL(token);return url ? isImageURL(url) : false;},})

Const ImplementsIcon

ImplementsIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_ImplementsIcon)

Const KeyboardShortcutIcon

KeyboardShortcutIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_KeyboardShortcutIcon)

Const MagnifyingGlassIcon

MagnifyingGlassIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_MagnifyingGlassIcon)

Const MarkdownContent

MarkdownContent: ForwardRefExoticComponent<Omit<MarkdownContentProps & Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "children">, "ref"> & RefAttributes<HTMLDivElement>> = forwardRef<HTMLDivElement,MarkdownContentProps & Omit<JSX.IntrinsicElements['div'], 'children'>>(({ children, onlyShowFirstChild, type, ...props }, ref) => (<div{...props}ref={ref}className={clsx(`graphiql-markdown-${type}`,onlyShowFirstChild && 'graphiql-markdown-preview',props.className,)}dangerouslySetInnerHTML={{ __html: markdown.render(children) }}/>))

Const MergeIcon

MergeIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_MergeIcon)

Const PenIcon

PenIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_PenIcon)

Const PlayIcon

PlayIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_PlayIcon)

Const PlusIcon

PlusIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_PlusIcon)

Const PrettifyIcon

PrettifyIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_PrettifyIcon)

Const ReloadIcon

ReloadIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_ReloadIcon)

Const RootTypeIcon

RootTypeIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_RootTypeIcon)

Const STORAGE_KEY

STORAGE_KEY: "variables" = "variables"

Const STORAGE_KEY

STORAGE_KEY: "tabState" = "tabState"

Const STORAGE_KEY

STORAGE_KEY: "headers" = "headers"

Const STORAGE_KEY_QUERY

STORAGE_KEY_QUERY: "query" = "query"

Const SettingsIcon

SettingsIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_SettingsIcon)

Const Spinner

Spinner: ForwardRefExoticComponent<Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & RefAttributes<HTMLDivElement>> = forwardRef<HTMLDivElement, JSX.IntrinsicElements['div']>((props, ref) => (<div{...props}ref={ref}className={clsx('graphiql-spinner', props.className)}/>),)

Const StarFilledIcon

StarFilledIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_StarFilledIcon)

Const StarIcon

StarIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_StarIcon)

Const StopIcon

StopIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_StopIcon)

Const Tab

Tab: ForwardRefExoticComponent<TabProps & RefAttributes<HTMLLIElement>> & { Button: ForwardRefExoticComponent<Omit<DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & RefAttributes<HTMLButtonElement>>; Close: ForwardRefExoticComponent<Omit<DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & RefAttributes<HTMLButtonElement>> } = Object.assign(TabRoot, {Button: TabButton,Close: TabClose,})

Const Tabs

Tabs: ForwardRefExoticComponent<TabsProps & RefAttributes<HTMLUListElement>> = forwardRef<HTMLUListElement, TabsProps>(({ values, onReorder, children, className, ...props }, ref) => (<Reorder.Group{...props}ref={ref}values={values}onReorder={onReorder}axis="x"role="tablist"className={clsx('graphiql-tabs', className)}>{children}</Reorder.Group>),)

Const ToolbarButton

ToolbarButton: ForwardRefExoticComponent<Omit<ToolbarButtonProps & ClassAttributes<HTMLButtonElement> & ButtonHTMLAttributes<HTMLButtonElement>, "ref"> & RefAttributes<HTMLButtonElement>> = forwardRef<HTMLButtonElement,ToolbarButtonProps & JSX.IntrinsicElements['button']>(({ label, onClick, ...props }, ref) => {const [error, setError] = useState<Error | null>(null);const handleClick: MouseEventHandler<HTMLButtonElement> = event => {try {// Optional chaining inside try-catch isn't supported yet by react-compilerif (onClick) {onClick(event);}setError(null);} catch (err) {setError(err instanceof Error? err: new Error(`Toolbar button click failed: ${err}`),);}};return (<Tooltip label={label}><UnStyledButton{...props}ref={ref}type="button"className={clsx('graphiql-toolbar-button',error && 'error',props.className,)}onClick={handleClick}aria-label={error ? error.message : label}aria-invalid={error ? 'true' : props['aria-invalid']}/></Tooltip>);})

Const ToolbarMenu

ToolbarMenu: ToolbarMenuRoot & { Item: FC<DropdownMenuItemProps> } = Object.assign(ToolbarMenuRoot, {Item: DropdownMenu.Item,})

Const Tooltip

Tooltip: FC<TooltipContentProps & { label: ReactNode }> & { Provider: FC<TooltipProviderProps> } = Object.assign(TooltipRoot, {Provider: T.Provider,})

Const TrashIcon

TrashIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_TrashIcon)

Const TypeIcon

TypeIcon: FC<SVGProps<SVGSVGElement>> = generateIcon(_TypeIcon)

Const UnStyledButton

UnStyledButton: ForwardRefExoticComponent<Omit<DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & RefAttributes<HTMLButtonElement>> = forwardRef<HTMLButtonElement,JSX.IntrinsicElements['button']>((props, ref) => (<button{...props}ref={ref}className={clsx('graphiql-un-styled', props.className)}/>))

Const createBoundedUseStore

createBoundedUseStore: <S>(store: S) => { (): ExtractState<S>; <T>(selector: (state: ExtractState<S>) => T): T } = (store => selector =>useStore(store, selector)) as <S extends StoreApi<unknown>>(store: S,) => {(): ExtractState<S>;<T>(selector: (state: ExtractState<S>) => T): T;}

Type declaration

    • <S>(store: S): { (): ExtractState<S>; <T>(selector: (state: ExtractState<S>) => T): T }
    • Type parameters

      • S: StoreApi<unknown>

      Parameters

      • store: S

      Returns { (): ExtractState<S>; <T>(selector: (state: ExtractState<S>) => T): T }

        • (): ExtractState<S>
        • <T>(selector: (state: ExtractState<S>) => T): T
        • Returns ExtractState<S>

        • Type parameters

          • T

          Parameters

          • selector: (state: ExtractState<S>) => T
              • (state: ExtractState<S>): T
              • Parameters

                • state: ExtractState<S>

                Returns T

          Returns T

Const editorStore

editorStore: StoreApi<EditorStore> = createStore<EditorStore>((set, get) => ({tabs: null!,activeTabIndex: null!,addTab() {set(current => {const { defaultQuery, defaultHeaders, onTabChange } = get();// Make sure the current tab stores the latest valuesconst updatedValues = synchronizeActiveTabValues(current);const updated = {tabs: [...updatedValues.tabs,createTab({headers: defaultHeaders,query: defaultQuery,}),],activeTabIndex: updatedValues.tabs.length,};storeTabs(updated);setEditorValues(updated.tabs[updated.activeTabIndex]);onTabChange?.(updated);return updated;});},changeTab(index) {set(current => {const { onTabChange } = get();const updated = {...current,activeTabIndex: index,};storeTabs(updated);setEditorValues(updated.tabs[updated.activeTabIndex]);onTabChange?.(updated);return updated;});},moveTab(newOrder) {set(current => {const { onTabChange } = get();const activeTab = current.tabs[current.activeTabIndex];const updated = {tabs: newOrder,activeTabIndex: newOrder.indexOf(activeTab),};storeTabs(updated);setEditorValues(updated.tabs[updated.activeTabIndex]);onTabChange?.(updated);return updated;});},closeTab(index) {set(current => {const { onTabChange } = get();const updated = {tabs: current.tabs.filter((_tab, i) => index !== i),activeTabIndex: Math.max(current.activeTabIndex - 1, 0),};storeTabs(updated);setEditorValues(updated.tabs[updated.activeTabIndex]);onTabChange?.(updated);return updated;});},updateActiveTabValues(partialTab) {set(current => {if (!current.tabs) {// Vitest fails with TypeError: Cannot read properties of null (reading 'map')// in `setPropertiesInActiveTab` when `tabs` is `null`return current;}const { onTabChange } = get();const updated = setPropertiesInActiveTab(current, partialTab);storeTabs(updated);onTabChange?.(updated);return updated;});},headerEditor: null!,queryEditor: null!,responseEditor: null!,variableEditor: null!,setHeaderEditor(headerEditor) {set({ headerEditor });},setQueryEditor(queryEditor) {set({ queryEditor });},setResponseEditor(responseEditor) {set({ responseEditor });},setVariableEditor(variableEditor) {set({ variableEditor });},setOperationName(operationName) {const { queryEditor, onEditOperationName, updateActiveTabValues } = get();if (!queryEditor) {return;}queryEditor.operationName = operationName;updateActiveTabValues({ operationName });onEditOperationName?.(operationName);},shouldPersistHeaders: false,setShouldPersistHeaders(persist) {const { headerEditor, tabs, activeTabIndex } = get();const { storage } = storageStore.getState();if (persist) {storage.set(STORAGE_KEY_HEADERS, headerEditor?.getValue() ?? '');const serializedTabs = serializeTabState({ tabs, activeTabIndex }, true);storage.set(STORAGE_KEY_TABS, serializedTabs);} else {storage.set(STORAGE_KEY_HEADERS, '');clearHeadersFromTabs();}set({ shouldPersistHeaders: persist });storage.set(PERSIST_HEADERS_STORAGE_KEY, persist.toString());},onEditOperationName: undefined,externalFragments: null!,onTabChange: undefined,defaultQuery: undefined,defaultHeaders: undefined,validationRules: null!,initialHeaders: null!,initialQuery: null!,initialResponse: null!,initialVariables: null!,}))

Const executionStore

executionStore: StoreApi<ExecutionContextType & Pick<ExecutionContextProviderProps, "getDefaultFieldNames">> = createStore<ExecutionContextType &Pick<ExecutionContextProviderProps, 'getDefaultFieldNames'>>((set, get) => ({isFetching: false,subscription: null,operationName: null,getDefaultFieldNames: undefined,queryId: 0,stop() {const { subscription } = get();subscription?.unsubscribe();set({ isFetching: false, subscription: null });},async run() {const {externalFragments,headerEditor,queryEditor,responseEditor,variableEditor,updateActiveTabValues,} = editorStore.getState();if (!queryEditor || !responseEditor) {return;}const { subscription, operationName, queryId } = get();// If there's an active subscription, unsubscribe it and returnif (subscription) {stop();return;}const setResponse = (value: string) => {responseEditor.setValue(value);updateActiveTabValues({ response: value });};const newQueryId = queryId + 1;set({ queryId: newQueryId });// Use the edited query after autoCompleteLeafs() runs or,// in case autoCompletion fails (the function returns undefined),// the current query from the editor.let query = getAutoCompleteLeafs() || queryEditor.getValue();const variablesString = variableEditor?.getValue();let variables: Record<string, unknown> | undefined;try {variables = tryParseJsonObject({json: variablesString,errorMessageParse: 'Variables are invalid JSON',errorMessageType: 'Variables are not a JSON object.',});} catch (error) {setResponse(error instanceof Error ? error.message : `${error}`);return;}const headersString = headerEditor?.getValue();let headers: Record<string, unknown> | undefined;try {headers = tryParseJsonObject({json: headersString,errorMessageParse: 'Headers are invalid JSON',errorMessageType: 'Headers are not a JSON object.',});} catch (error) {setResponse(error instanceof Error ? error.message : `${error}`);return;}if (externalFragments) {const fragmentDependencies = queryEditor.documentAST? getFragmentDependenciesForAST(queryEditor.documentAST,externalFragments,): [];if (fragmentDependencies.length > 0) {query +='\n' +fragmentDependencies.map((node: FragmentDefinitionNode) => print(node)).join('\n');}}setResponse('');set({ isFetching: true });try {const fullResponse: ExecutionResult = {};const handleResponse = (result: ExecutionResult) => {// A different query was dispatched in the meantime, so don't// show the results of this one.if (newQueryId !== get().queryId) {return;}let maybeMultipart = Array.isArray(result) ? result : false;if (!maybeMultipart &&typeof result === 'object' &&result !== null &&'hasNext' in result) {maybeMultipart = [result];}if (maybeMultipart) {for (const part of maybeMultipart) {mergeIncrementalResult(fullResponse, part);}set({ isFetching: false });setResponse(formatResult(fullResponse));} else {set({ isFetching: false });setResponse(formatResult(result));}};const { fetcher } = schemaStore.getState();const fetch = fetcher({query,variables,operationName:operationName ?? queryEditor.operationName ?? undefined,},{headers: headers ?? undefined,documentAST: queryEditor.documentAST ?? undefined,},);const value = await fetch;if (isObservable(value)) {// If the fetcher returned an Observable, then subscribe to it, calling// the callback on each next value and handling both errors and the// completion of the Observable.const newSubscription = value.subscribe({next(result) {handleResponse(result);},error(error: Error) {set({ isFetching: false });if (error) {setResponse(formatError(error));}set({ subscription: null });},complete() {set({ isFetching: false, subscription: null });},});set({ subscription: newSubscription });} else if (isAsyncIterable(value)) {const newSubscription = {unsubscribe: () => value[Symbol.asyncIterator]().return?.(),};set({ subscription: newSubscription });for await (const result of value) {handleResponse(result);}set({ isFetching: false, subscription: null });} else {handleResponse(value);}} catch (error) {set({ isFetching: false });setResponse(formatError(error));set({ subscription: null });}},}))

Const invalidCharacters

invalidCharacters: string[] = Array.from({ length: 11 }, (_, i) => {// \u2000 -> \u200areturn String.fromCharCode(0x2000 + i);}).concat(['\u2028', '\u2029', '\u202f', '\u00a0'])

Const isMacOs

isMacOs: boolean = typeof navigator !== 'undefined' && navigator.userAgent.includes('Mac')

Const markdown

markdown: MarkdownIt = new MarkdownIt({// we don't want to convert \n to <br> because in markdown a single newline is not a line break// https://github.com/graphql/graphiql/issues/3155breaks: false,linkify: true,})

Const pluginStore

pluginStore: StoreApi<PluginContextType> = createStore<PluginContextType>((set, get) => ({plugins: [],visiblePlugin: null,referencePlugin: undefined,setVisiblePlugin(plugin) {const { plugins, onTogglePluginVisibility } = get();const byTitle = typeof plugin === 'string';const newVisiblePlugin: PluginContextType['visiblePlugin'] =(plugin && plugins.find(p => (byTitle ? p.title : p) === plugin)) || null;set(({ visiblePlugin }) => {if (newVisiblePlugin === visiblePlugin) {return { visiblePlugin };}onTogglePluginVisibility?.(newVisiblePlugin);return { visiblePlugin: newVisiblePlugin };});},}))

Const schemaStore

schemaStore: StoreApi<SchemaStore> = createStore<SchemaStore>((set, get) => ({inputValueDeprecation: null!,introspectionQueryName: null!,schemaDescription: null!,fetcher: null!, // Explicitly set to null, as it's safe since we have TypeError thrownonSchemaChange: undefined,fetchError: null,isFetching: false,schema: null,/*** Derive validation errors from the schema*/validationErrors: [],schemaReference: null,setSchemaReference(schemaReference) {set({ schemaReference });},requestCounter: 0,shouldIntrospect: true,/*** Fetch the schema*/async introspect() {const {requestCounter,fetcher,onSchemaChange,shouldIntrospect,...rest} = get();/*** Only introspect if there is no schema provided via props. If the* prop is passed an introspection result, we do continue but skip the* introspection request.*/if (!shouldIntrospect) {return;}const counter = requestCounter + 1;set({ requestCounter: counter });try {const { headerEditor } = editorStore.getState();const currentHeaders = headerEditor?.getValue();const parsedHeaders = parseHeaderString(currentHeaders);if (!parsedHeaders.isValidJSON) {set({ fetchError: 'Introspection failed as headers are invalid.' });return;}const fetcherOpts: FetcherOpts = parsedHeaders.headers? { headers: parsedHeaders.headers }: {};/*** Get an introspection query for settings given via props*/const {introspectionQuery,introspectionQueryName,introspectionQuerySansSubscriptions,} = generateIntrospectionQuery(rest);const fetch = fetcherReturnToPromise(fetcher({query: introspectionQuery,operationName: introspectionQueryName,},fetcherOpts,),);if (!isPromise(fetch)) {set({fetchError: 'Fetcher did not return a Promise for introspection.',});return;}set({ isFetching: true, fetchError: null });let result = await fetch;if (typeof result !== 'object' ||result === null ||!('data' in result)) {// Try the stock introspection query first, falling back on the// sans-subscriptions query for services which do not yet support it.const fetch2 = fetcherReturnToPromise(fetcher({query: introspectionQuerySansSubscriptions,operationName: introspectionQueryName,},fetcherOpts,),);if (!isPromise(fetch2)) {throw new Error('Fetcher did not return a Promise for introspection.',);}result = await fetch2;}set({ isFetching: false });let introspectionData: IntrospectionQuery | undefined;if (result?.data && '__schema' in result.data) {introspectionData = result.data as IntrospectionQuery;} else {// handle as if it were an error if the fetcher response is not a string or response.data is not presentconst responseString =typeof result === 'string' ? result : formatResult(result);set({ fetchError: responseString });}/*** Don't continue if another introspection request has been started in* the meantime or if there is no introspection data.*/if (counter !== get().requestCounter || !introspectionData) {return;}const newSchema = buildClientSchema(introspectionData);set({ schema: newSchema });onSchemaChange?.(newSchema);} catch (error) {/*** Don't continue if another introspection request has been started in* the meantime.*/if (counter !== get().requestCounter) {return;}set({fetchError: formatError(error),isFetching: false,});}},}))

Const storageStore

storageStore: StoreApi<StorageContextType> = createStore<StorageContextType>(() => ({storage: null!,}))

Const useEditorStore

useEditorStore: { (): ExtractState<S>; <T>(selector: (state: ExtractState<S>) => T): T } = createBoundedUseStore(editorStore)

Type declaration

    • (): ExtractState<S>
    • <T>(selector: (state: ExtractState<S>) => T): T
    • Returns ExtractState<S>

    • Type parameters

      • T

      Parameters

      • selector: (state: ExtractState<S>) => T
          • (state: ExtractState<S>): T
          • Parameters

            • state: ExtractState<S>

            Returns T

      Returns T

Const useExecutionStore

useExecutionStore: { (): ExtractState<S>; <T>(selector: (state: ExtractState<S>) => T): T } = createBoundedUseStore(executionStore)

Type declaration

    • (): ExtractState<S>
    • <T>(selector: (state: ExtractState<S>) => T): T
    • Returns ExtractState<S>

    • Type parameters

      • T

      Parameters

      • selector: (state: ExtractState<S>) => T
          • (state: ExtractState<S>): T
          • Parameters

            • state: ExtractState<S>

            Returns T

      Returns T

Const usePluginStore

usePluginStore: { (): ExtractState<S>; <T>(selector: (state: ExtractState<S>) => T): T } = createBoundedUseStore(pluginStore)

Type declaration

    • (): ExtractState<S>
    • <T>(selector: (state: ExtractState<S>) => T): T
    • Returns ExtractState<S>

    • Type parameters

      • T

      Parameters

      • selector: (state: ExtractState<S>) => T
          • (state: ExtractState<S>): T
          • Parameters

            • state: ExtractState<S>

            Returns T

      Returns T

Const useSchemaStore

useSchemaStore: { (): ExtractState<S>; <T>(selector: (state: ExtractState<S>) => T): T } = createBoundedUseStore(schemaStore)

Type declaration

    • (): ExtractState<S>
    • <T>(selector: (state: ExtractState<S>) => T): T
    • Returns ExtractState<S>

    • Type parameters

      • T

      Parameters

      • selector: (state: ExtractState<S>) => T
          • (state: ExtractState<S>): T
          • Parameters

            • state: ExtractState<S>

            Returns T

      Returns T

Functions

Const DialogRoot

  • DialogRoot(__namedParameters: { children: ReactNode; props: props }): Element

Const EditorContextProvider

  • EditorContextProvider(__namedParameters: { children: ReactNode; defaultHeaders: undefined | string; defaultQuery: undefined | string; externalFragments: undefined | string | FragmentDefinitionNode[]; onEditOperationName: undefined | onEditOperationName; onTabChange: undefined | onTabChange; props: props; shouldPersistHeaders: boolean; validationRules: ValidationRule[] }): null | ReactElement<unknown, string | ((props: P) => ReactElement<any, any> | null) | {}>
  • Parameters

    • __namedParameters: { children: ReactNode; defaultHeaders: undefined | string; defaultQuery: undefined | string; externalFragments: undefined | string | FragmentDefinitionNode[]; onEditOperationName: undefined | onEditOperationName; onTabChange: undefined | onTabChange; props: props; shouldPersistHeaders: boolean; validationRules: ValidationRule[] }
      • children: ReactNode
      • defaultHeaders: undefined | string
      • defaultQuery: undefined | string
      • externalFragments: undefined | string | FragmentDefinitionNode[]
      • onEditOperationName: undefined | onEditOperationName
      • onTabChange: undefined | onTabChange
      • props: props
      • shouldPersistHeaders: boolean
      • validationRules: ValidationRule[]

    Returns null | ReactElement<unknown, string | ((props: P) => ReactElement<any, any> | null) | {}>

Const ExecuteButton

  • ExecuteButton(): Element

Const ExecutionContextProvider

  • ExecutionContextProvider(__namedParameters: { children: ReactNode; fetcher: Fetcher; getDefaultFieldNames: undefined | GetDefaultFieldNamesFn; operationName: null | string }): ReactElement<unknown, string | ((props: P) => ReactElement<any, any> | null) | {}>

Const GraphiQLProvider

  • GraphiQLProvider(__namedParameters: { children: ReactNode; dangerouslyAssumeSchemaIsValid: undefined | false | true; defaultHeaders: undefined | string; defaultQuery: undefined | string; defaultTabs: undefined | TabDefinition[]; externalFragments: undefined | string | FragmentDefinitionNode[]; fetcher: Fetcher; getDefaultFieldNames: undefined | GetDefaultFieldNamesFn; headers: undefined | string; inputValueDeprecation: undefined | false | true; introspectionQueryName: undefined | string; onEditOperationName: undefined | onEditOperationName; onSchemaChange: undefined | onSchemaChange; onTabChange: undefined | onTabChange; onTogglePluginVisibility: undefined | onTogglePluginVisibility; operationName: undefined | string; plugins: undefined | GraphiQLPlugin[]; query: undefined | string; referencePlugin: undefined | GraphiQLPlugin; response: undefined | string; schema: undefined | null | GraphQLSchema | IntrospectionQuery; schemaDescription: undefined | false | true; shouldPersistHeaders: undefined | false | true; storage: undefined | Storage; validationRules: undefined | ValidationRule[]; variables: undefined | string; visiblePlugin: undefined | string | GraphiQLPlugin }): Element
  • Parameters

    • __namedParameters: { children: ReactNode; dangerouslyAssumeSchemaIsValid: undefined | false | true; defaultHeaders: undefined | string; defaultQuery: undefined | string; defaultTabs: undefined | TabDefinition[]; externalFragments: undefined | string | FragmentDefinitionNode[]; fetcher: Fetcher; getDefaultFieldNames: undefined | GetDefaultFieldNamesFn; headers: undefined | string; inputValueDeprecation: undefined | false | true; introspectionQueryName: undefined | string; onEditOperationName: undefined | onEditOperationName; onSchemaChange: undefined | onSchemaChange; onTabChange: undefined | onTabChange; onTogglePluginVisibility: undefined | onTogglePluginVisibility; operationName: undefined | string; plugins: undefined | GraphiQLPlugin[]; query: undefined | string; referencePlugin: undefined | GraphiQLPlugin; response: undefined | string; schema: undefined | null | GraphQLSchema | IntrospectionQuery; schemaDescription: undefined | false | true; shouldPersistHeaders: undefined | false | true; storage: undefined | Storage; validationRules: undefined | ValidationRule[]; variables: undefined | string; visiblePlugin: undefined | string | GraphiQLPlugin }
      • children: ReactNode
      • dangerouslyAssumeSchemaIsValid: undefined | false | true
      • defaultHeaders: undefined | string
      • defaultQuery: undefined | string
      • defaultTabs: undefined | TabDefinition[]
      • externalFragments: undefined | string | FragmentDefinitionNode[]
      • fetcher: Fetcher
      • getDefaultFieldNames: undefined | GetDefaultFieldNamesFn
      • headers: undefined | string
      • inputValueDeprecation: undefined | false | true
      • introspectionQueryName: undefined | string
      • onEditOperationName: undefined | onEditOperationName
      • onSchemaChange: undefined | onSchemaChange
      • onTabChange: undefined | onTabChange
      • onTogglePluginVisibility: undefined | onTogglePluginVisibility
      • operationName: undefined | string
      • plugins: undefined | GraphiQLPlugin[]
      • query: undefined | string
      • referencePlugin: undefined | GraphiQLPlugin
      • response: undefined | string
      • schema: undefined | null | GraphQLSchema | IntrospectionQuery
      • schemaDescription: undefined | false | true
      • shouldPersistHeaders: undefined | false | true
      • storage: undefined | Storage
      • validationRules: undefined | ValidationRule[]
      • variables: undefined | string
      • visiblePlugin: undefined | string | GraphiQLPlugin

    Returns Element

Const HeaderEditor

  • HeaderEditor(__namedParameters: { hookArgs: hookArgs; isHidden: undefined | false | true }): Element

Const PluginContextProvider

  • PluginContextProvider(__namedParameters: { children: ReactNode; onTogglePluginVisibility: undefined | onTogglePluginVisibility; plugins: GraphiQLPlugin[]; referencePlugin: undefined | GraphiQLPlugin; visiblePlugin: undefined | string | GraphiQLPlugin }): ReactElement<unknown, string | ((props: P) => ReactElement<any, any> | null) | {}>

Const QueryEditor

Const ResponseEditor

Const SchemaContextProvider

  • SchemaContextProvider(__namedParameters: { children: ReactNode; dangerouslyAssumeSchemaIsValid: boolean; fetcher: Fetcher; inputValueDeprecation: boolean; introspectionQueryName: string; onSchemaChange: undefined | onSchemaChange; schema: undefined | null | GraphQLSchema | IntrospectionQuery; schemaDescription: boolean }): ReactElement<unknown, string | ((props: P) => ReactElement<any, any> | null) | {}>
  • Parameters

    • __namedParameters: { children: ReactNode; dangerouslyAssumeSchemaIsValid: boolean; fetcher: Fetcher; inputValueDeprecation: boolean; introspectionQueryName: string; onSchemaChange: undefined | onSchemaChange; schema: undefined | null | GraphQLSchema | IntrospectionQuery; schemaDescription: boolean }
      • children: ReactNode
      • dangerouslyAssumeSchemaIsValid: boolean
      • fetcher: Fetcher
      • inputValueDeprecation: boolean
      • introspectionQueryName: string
      • onSchemaChange: undefined | onSchemaChange
      • schema: undefined | null | GraphQLSchema | IntrospectionQuery
      • schemaDescription: boolean

    Returns ReactElement<unknown, string | ((props: P) => ReactElement<any, any> | null) | {}>

Const StorageContextProvider

  • StorageContextProvider(__namedParameters: { children: ReactNode; storage: undefined | Storage }): null | ReactElement<unknown, string | ((props: P) => ReactElement<any, any> | null) | {}>
  • Parameters

    • __namedParameters: { children: ReactNode; storage: undefined | Storage }
      • children: ReactNode
      • storage: undefined | Storage

    Returns null | ReactElement<unknown, string | ((props: P) => ReactElement<any, any> | null) | {}>

Const TooltipRoot

  • TooltipRoot(__namedParameters: { align: "center" | "start" | "end"; children: ReactNode; label: ReactNode; side: "top" | "right" | "bottom" | "left"; sideOffset: number }): Element
  • Parameters

    • __namedParameters: { align: "center" | "start" | "end"; children: ReactNode; label: ReactNode; side: "top" | "right" | "bottom" | "left"; sideOffset: number }
      • align: "center" | "start" | "end"
      • children: ReactNode
      • label: ReactNode
      • side: "top" | "right" | "bottom" | "left"
      • sideOffset: number

    Returns Element

Const VariableEditor

  • VariableEditor(__namedParameters: { hookArgs: hookArgs; isHidden: undefined | false | true }): Element

clearHeadersFromTabs

createTab

  • createTab(__namedParameters?: { headers: null | string; query: null | string; variables: null | string }): TabState

debounce

  • debounce<F>(duration: number, fn: F): debounce

fuzzyExtractOperationName

  • fuzzyExtractOperationName(str: string): string | null

getAutoCompleteLeafs

getDefaultTabState

  • getDefaultTabState(__namedParameters: { defaultHeaders: undefined | string; defaultQuery: string; defaultTabs: undefined | TabDefinition[]; headers: null | string; query: null | string; shouldPersistHeaders: undefined | false | true; variables: null | string }): getDefaultTabState
  • Parameters

    • __namedParameters: { defaultHeaders: undefined | string; defaultQuery: string; defaultTabs: undefined | TabDefinition[]; headers: null | string; query: null | string; shouldPersistHeaders: undefined | false | true; variables: null | string }
      • defaultHeaders: undefined | string
      • defaultQuery: string
      • defaultTabs: undefined | TabDefinition[]
      • headers: null | string
      • query: null | string
      • shouldPersistHeaders: undefined | false | true
      • variables: null | string

    Returns getDefaultTabState

importCodeMirror

  • importCodeMirror(addons: Promise<any>[], options?: undefined | { useCommonAddons?: undefined | false | true }): importCodeMirror

normalizeWhitespace

onHasCompletion

  • onHasCompletion(_cm: Editor, data: EditorChange | undefined, __namedParameters: { schema: MaybeGraphQLSchema; setSchemaReference: Dispatch<SchemaReference> }, plugin: PluginContextType | null, callback?: undefined | ((type: GraphQLNamedType) => void)): void
  • Render a custom UI for CodeMirror's hint which includes additional info about the type and description for the selected context.

    Parameters

    • _cm: Editor
    • data: EditorChange | undefined
    • __namedParameters: { schema: MaybeGraphQLSchema; setSchemaReference: Dispatch<SchemaReference> }
    • plugin: PluginContextType | null
    • Optional callback: undefined | ((type: GraphQLNamedType) => void)

    Returns void

serializeTabState

setEditorValues

  • setEditorValues(__namedParameters: { headers: undefined | null | string; query: null | string; response: null | string; variables: undefined | null | string }): setEditorValues
  • Parameters

    • __namedParameters: { headers: undefined | null | string; query: null | string; response: null | string; variables: undefined | null | string }
      • headers: undefined | null | string
      • query: null | string
      • response: null | string
      • variables: undefined | null | string

    Returns setEditorValues

setPropertiesInActiveTab

storeTabs

  • storeTabs(__namedParameters: { activeTabIndex: number; tabs: TabState[] }): storeTabs

synchronizeActiveTabValues

useChangeHandler

  • useChangeHandler(editor: CodeMirrorEditor | null, callback: ((value: string) => void) | undefined, storageKey: string | null, tabProperty: "variables" | "headers"): useChangeHandler

useCompletion

useCopyQuery

  • useCopyQuery(__namedParameters?: { onCopyQuery: undefined | ((query: string) => void) }): useCopyQuery

useDragResize

  • useDragResize(__namedParameters: { defaultSizeRelation: number; direction: "horizontal" | "vertical"; initiallyHidden: undefined | "first" | "second"; onHiddenElementChange: undefined | onHiddenElementChange; sizeThresholdFirst: number; sizeThresholdSecond: number; storageKey: undefined | string }): useDragResize
  • Parameters

    • __namedParameters: { defaultSizeRelation: number; direction: "horizontal" | "vertical"; initiallyHidden: undefined | "first" | "second"; onHiddenElementChange: undefined | onHiddenElementChange; sizeThresholdFirst: number; sizeThresholdSecond: number; storageKey: undefined | string }
      • defaultSizeRelation: number
      • direction: "horizontal" | "vertical"
      • initiallyHidden: undefined | "first" | "second"
      • onHiddenElementChange: undefined | onHiddenElementChange
      • sizeThresholdFirst: number
      • sizeThresholdSecond: number
      • storageKey: undefined | string

    Returns useDragResize

Const useEditorState

  • useEditorState(editor: "query" | "variable" | "header"): [string, (val: string) => void]

useHeaderEditor

  • useHeaderEditor(__namedParameters?: { editorTheme: string; keyMap: KeyMap; onEdit: undefined | onEdit; readOnly: boolean }): useHeaderEditor

Const useHeadersEditorState

  • useHeadersEditorState(): [headers: string, setHeaders: (content: string) => void]

useKeyMap

useMergeQuery

Const useOperationsEditorState

  • useOperationsEditorState(): [operations: string, setOperations: (content: string) => void]

useOptimisticState

  • useOptimisticState(__namedParameters: [string, (val: string) => void]): ReturnType<typeof useEditorState>
  • Implements an optimistic caching strategy around a useState-like hook in order to prevent loss of updates when the hook has an internal delay and the update function is called again before the updated state is sent out.

    Use this as a wrapper around useOperationsEditorState, useVariablesEditorState, or useHeadersEditorState if you anticipate calling them with great frequency (due to, for instance, mouse, keyboard, or network events).

    example
    const [operationsString, handleEditOperations] =
      useOptimisticState(useOperationsEditorState());

    Parameters

    • __namedParameters: [string, (val: string) => void]

    Returns ReturnType<typeof useEditorState>

usePrettifyEditors

useQueryEditor

  • useQueryEditor(__namedParameters?: { editorTheme: string; keyMap: KeyMap; onClickReference: undefined | onClickReference; onCopyQuery: undefined | ((query: string) => void); onEdit: undefined | onEdit; onPrettifyQuery: undefined | ((query: string) => MaybePromise<string>); readOnly: boolean }, caller?: Function): useQueryEditor

useResponseEditor

  • useResponseEditor(__namedParameters?: { editorTheme: string; keyMap: KeyMap; responseTooltip: undefined | ComponentClass<{ pos: Position; token: Token }, any> | FunctionComponent<{ pos: Position; token: Token }> }): useResponseEditor
  • Parameters

    • Default value __namedParameters: { editorTheme: string; keyMap: KeyMap; responseTooltip: undefined | ComponentClass<{ pos: Position; token: Token }, any> | FunctionComponent<{ pos: Position; token: Token }> } = {}
      • editorTheme: string
      • keyMap: KeyMap
      • responseTooltip: undefined | ComponentClass<{ pos: Position; token: Token }, any> | FunctionComponent<{ pos: Position; token: Token }>

    Returns useResponseEditor

Const useStorage

  • useStorage(): StorageAPI

useSynchronizeOption

useSynchronizeValue

useTheme

useVariableEditor

Const useVariablesEditorState

  • useVariablesEditorState(): [variables: string, setVariables: (content: string) => void]

Object literals

Const commonKeys

commonKeys: object

Alt-Left

Alt-Left: string = "goGroupLeft"

Alt-Right

Alt-Right: string = "goGroupRight"

Cmd-G

Cmd-G: string = "findPersistent"

Ctrl-G

Ctrl-G: string = "findPersistent"

Ctrl-Left

Ctrl-Left: string = "goSubwordLeft"

Ctrl-Right

Ctrl-Right: string = "goSubwordRight"

[isMacOs ? 'Cmd-F' : 'Ctrl-F']

[isMacOs ? 'Cmd-F' : 'Ctrl-F']: string = "findPersistent"

Generated using TypeDoc