GraphiQL API Documentation
    Preparing search index...

    Interface SlicesWithActions

    interface SlicesWithActions {
        abortController: AbortController | null;
        actions: AllActions;
        activeTabIndex: number;
        customScalarSchemas?: Record<string, JSONSchema6>;
        defaultHeaders?: string;
        defaultQuery?: string;
        documentAST?: DocumentNode;
        editorTheme: { dark: MonacoTheme; light: MonacoTheme };
        executingOperation?: OperationDefinitionNode;
        externalFragments: Map<string, FragmentDefinitionNode>;
        fetcher?: Fetcher;
        fetchError: string | null;
        getDefaultFieldNames?: GetDefaultFieldNamesFn;
        headerEditor?: IStandaloneCodeEditor;
        initialHeaders: string;
        initialQuery: string;
        initialVariables: string;
        inputValueDeprecation?: boolean;
        introspectionQueryName?: string;
        isFetching: boolean;
        isIntrospecting: boolean;
        lastResponse: TransportResponse | null;
        onCopyQuery?: (query: string) => void;
        onPrettifyQuery: (query: string) => MaybePromise<string>;
        onSchemaChange?: (schema: GraphQLSchema) => void;
        operationName?: string;
        operations?: OperationDefinitionNode[];
        plugins: GraphiQLPlugin[];
        queryEditor?: IStandaloneCodeEditor;
        queryId: number;
        referencePlugin?: GraphiQLPlugin | null;
        requestCounter: number;
        responseEditor?: IStandaloneCodeEditor;
        responseView: ResponseView;
        saveError: string | null;
        saveHandlers: Set<SaveHandler>;
        savingTabIds: Set<string>;
        schema: MaybeGraphQLSchema;
        schemaDescription?: boolean;
        schemaReference: SchemaReference | null;
        shouldIntrospect: boolean;
        shouldPersistHeaders: boolean;
        storage: StorageAPI;
        subscription: Unsubscribable | null;
        tabs: TabState[];
        theme: Theme;
        transport?: Transport;
        transportUpgradeBannerDismissed: boolean;
        uriInstanceId: string;
        validationErrors: readonly GraphQLError[];
        variableEditor?: IStandaloneCodeEditor;
        visiblePlugin: GraphiQLPlugin | null;
        onEditOperationName?(operationName: string): void;
        onTabChange?(tabState: TabsState): void;
        onTogglePluginVisibility?(visiblePlugin: GraphiQLPlugin | null): void;
    }

    Hierarchy

    • AllSlices
      • SlicesWithActions
    Index
    abortController: AbortController | null

    Aborts the in-flight request sent through transport. For queries and mutations this cancels the HTTP request outright. For streams it stays armed for the whole lifetime as a backstop that kills the underlying HTTP connection (e.g. a multipart/mixed incremental response) even if a link in the iterator-disposal chain fails to forward .return(); primary teardown is still subscription. null when nothing is in flight or when using the deprecated fetcher, which has no cancellation mechanism.

    null
    
    actions: AllActions
    activeTabIndex: number

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

    customScalarSchemas?: Record<string, JSONSchema6>

    JSON Schema fragments used to validate custom scalars in the variable editor. Without this, the variable editor's live JSON Schema linter assumes every custom scalar only accepts primitives (string, number, boolean, integer), and will report an "Incorrect type" error for any custom scalar that legitimately accepts an object or array (e.g. a JSON or GeoJSON scalar).

    Pass an empty object ({}) for a scalar to accept any JSON value, or a more specific schema to constrain it further.

    {
    customScalarSchemas: {
    GeoJSON: {},
    DateTime: { type: 'string', format: 'date-time' },
    }
    }
    defaultHeaders?: string

    Headers to be set when opening a new tab.

    defaultQuery?: string

    The initial content of the operation editor when loading GraphiQL and there is no saved query in storage and no initialQuery prop.

    This value is used only for the first tab. Additional tabs will open with an empty operation editor.

    "# Welcome to GraphiQL..."
    
    documentAST?: DocumentNode

    from graphiql 5

    editorTheme: { dark: MonacoTheme; light: MonacoTheme }
    executingOperation?: OperationDefinitionNode

    Operation captured from the last dispatched document. While fetching or subscribed, this identifies the request independently of editor changes.

    externalFragments: Map<string, FragmentDefinitionNode>

    A map of fragment definitions using the fragment name as a key which are made available to include in the query.

    fetcher?: Fetcher

    A function which accepts GraphQL HTTP parameters and returns a Promise, Observable or AsyncIterable that returns the GraphQL response in parsed JSON format.

    Pass a transport instead. The Fetcher contract cannot surface HTTP wire metadata (status, headers, timing, size). See docs/migration/graphiql-6.0.0.md.

    fetchError: string | null

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

    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.

    headerEditor?: IStandaloneCodeEditor

    The Monaco Editor instance used in the request headers editor, used to edit HTTP headers.

    initialHeaders: string

    The contents of the request headers editor when initially rendering the provider component.

    initialQuery: string

    The contents of the operation editor when initially rendering the provider component.

    initialVariables: string

    The contents of the variables editor when initially rendering the provider component.

    inputValueDeprecation?: boolean

    Can be used to set the equally named option for introspecting a GraphQL server.

    introspectionQueryName?: string

    Can be used to set a custom operation name for the introspection query.

    'IntrospectionQuery'
    
    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.

    false
    
    isIntrospecting: boolean

    If there currently is an introspection request in-flight.

    lastResponse: TransportResponse | null

    The full TransportResponse envelope from the most recent completed request. With a Transport, this carries the real HTTP wire metadata (status, headers, timing, size). With a Fetcher, only timing and size.response can be populated; status/headers are unavailable because the Fetcher contract does not carry them. null before any request runs.

    null
    
    onCopyQuery?: (query: string) => void

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

    Type Declaration

      • (query: string): void
      • Parameters

        • query: string

          The content that has been copied.

        Returns void

    onPrettifyQuery: (query: string) => MaybePromise<string>

    Invoked when the prettify callback is invoked.

    Type Declaration

      • (query: string): MaybePromise<string>
      • Parameters

        • query: string

          The current value of the operation editor.

        Returns MaybePromise<string>

        The formatted query.

    import prettier from 'prettier/standalone'

    prettier.format(query, { parser: 'graphql' })
    onSchemaChange?: (schema: GraphQLSchema) => void

    Type Declaration

      • (schema: GraphQLSchema): void
      • Invoked after a new GraphQL schema was built. This includes both fetching the schema via introspection and passing the schema using the schema prop.

        Parameters

        • schema: GraphQLSchema

          The GraphQL schema that is now used for GraphiQL.

        Returns void

    operationName?: string

    from graphiql 5

    operations?: OperationDefinitionNode[]

    from graphiql 5

    plugins: GraphiQLPlugin[]

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

    []
    
    queryEditor?: IStandaloneCodeEditor

    The Monaco Editor instance used in the operation editor.

    queryId: number
    0
    
    referencePlugin?: GraphiQLPlugin | null

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

    requestCounter: number

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

    responseEditor?: IStandaloneCodeEditor

    The Monaco Editor instance used in the response editor.

    responseView: ResponseView

    Which view is active in the response pane.

    'json'
    
    saveError: string | null

    The most recent save failure, shown beside the Save action.

    saveHandlers: Set<SaveHandler>

    Registered save handler. The dirty-state dot and Save button appear only when a plugin registers one.

    savingTabIds: Set<string>

    IDs of tabs whose save handler has not finished.

    schema: MaybeGraphQLSchema

    The current GraphQL schema.

    schemaDescription?: boolean

    Can be used to set the equally named option for introspecting a GraphQL server.

    schemaReference: SchemaReference | null

    The last type selected by the user.

    shouldIntrospect: boolean

    false when schema is provided via props as GraphQLSchema | null

    shouldPersistHeaders: boolean

    If the contents of the request headers editor are persisted in storage.

    storage: StorageAPI
    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.

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

    null
    
    tabs: TabState[]

    A list of state objects for each tab.

    theme: Theme
    transport?: Transport

    A Transport performs the GraphQL request and returns a TransportResponse carrying the parsed body plus the real HTTP wire metadata (status, headers, timing, size). Mutually exclusive with fetcher.

    transportUpgradeBannerDismissed: boolean

    Whether the user has dismissed the upgrade-to-transport banner in the response pane. Persisted to storage; honored by the response pane to decide whether to render any header at all in the fetcher path.

    false
    
    uriInstanceId: string

    Unique ID of the GraphiQL instance, which will be suffixed to the URIs for operations, variables, headers, and response editors.

    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.

    variableEditor?: IStandaloneCodeEditor

    The Monaco Editor instance used in the variables editor.

    visiblePlugin: GraphiQLPlugin | null

    The plugin which is currently visible.

    • Invoked when the operation name changes. Possible triggers are:

      • Editing the contents of the operation editor
      • Selecting an operation for execution in a document that contains multiple operation definitions

      Parameters

      • operationName: string

        The operation name after it has been changed.

      Returns void

    • Invoked when the state of the tabs changes. Possible triggers are:

      • Updating any editor contents inside the currently active tab
      • Adding a tab
      • Switching to a different tab
      • Closing a tab

      Parameters

      • tabState: TabsState

        The tab state after it has been updated.

      Returns 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