Options
All
  • Public
  • Public/Protected
  • All
Menu

Package graphiql-toolkit

Changelog | API Docs | NPM | Discord

@graphiql/toolkit

This is a general purpose library for building GraphQL IDEs. It's being used by other packages like graphiql and @graphiql/react and also provides utilities that are useful when working with these packages.

Docs

  • createFetcher : a utility for creating a fetcher prop implementation for HTTP GET, POST including multipart, websockets fetcher
  • more to come!

Index

References

Classes

Interfaces

Type aliases

Functions

References

CreateFetcherOptions

Re-exports CreateFetcherOptions

CreateFetcherOptions

Re-exports CreateFetcherOptions

CreateLocalStorageOptions

Re-exports CreateLocalStorageOptions

CreateLocalStorageOptions

Re-exports CreateLocalStorageOptions

ExecutionResultPayload

Re-exports ExecutionResultPayload

ExecutionResultPayload

Re-exports ExecutionResultPayload

Fetcher

Re-exports Fetcher

Fetcher

Re-exports Fetcher

FetcherOpts

Re-exports FetcherOpts

FetcherOpts

Re-exports FetcherOpts

FetcherParams

Re-exports FetcherParams

FetcherParams

Re-exports FetcherParams

FetcherResult

Re-exports FetcherResult

FetcherResult

Re-exports FetcherResult

FetcherResultPayload

Re-exports FetcherResultPayload

FetcherResultPayload

Re-exports FetcherResultPayload

FetcherReturnType

Re-exports FetcherReturnType

FetcherReturnType

Re-exports FetcherReturnType

GetDefaultFieldNamesFn

Re-exports GetDefaultFieldNamesFn

GetDefaultFieldNamesFn

Re-exports GetDefaultFieldNamesFn

HistoryStore

Re-exports HistoryStore

HistoryStore

Re-exports HistoryStore

MaybePromise

Re-exports MaybePromise

MaybePromise

Re-exports MaybePromise

Observable

Re-exports Observable

Observable

Re-exports Observable

QueryStore

Re-exports QueryStore

QueryStore

Re-exports QueryStore

QueryStoreItem

Re-exports QueryStoreItem

QueryStoreItem

Re-exports QueryStoreItem

Storage

Re-exports Storage

Storage

Re-exports Storage

StorageAPI

Re-exports StorageAPI

StorageAPI

Re-exports StorageAPI

SyncExecutionResult

Re-exports SyncExecutionResult

SyncExecutionResult

Re-exports SyncExecutionResult

SyncFetcherResult

Re-exports SyncFetcherResult

SyncFetcherResult

Re-exports SyncFetcherResult

Unsubscribable

Re-exports Unsubscribable

Unsubscribable

Re-exports Unsubscribable

createGraphiQLFetcher

Re-exports createGraphiQLFetcher

createGraphiQLFetcher

Re-exports createGraphiQLFetcher

createLocalStorage

Re-exports createLocalStorage

createLocalStorage

Re-exports createLocalStorage

fetcherReturnToPromise

Re-exports fetcherReturnToPromise

fillLeafs

Re-exports fillLeafs

fillLeafs

Re-exports fillLeafs

formatError

Re-exports formatError

formatResult

Re-exports formatResult

getSelectedOperationName

Re-exports getSelectedOperationName

getSelectedOperationName

Re-exports getSelectedOperationName

isAsyncIterable

Re-exports isAsyncIterable

isObservable

Re-exports isObservable

isPromise

Re-exports isPromise

mergeAst

Re-exports mergeAst

mergeAst

Re-exports mergeAst

Type aliases

CreateLocalStorageOptions

CreateLocalStorageOptions: { namespace?: undefined | string }

Type declaration

  • Optional namespace?: undefined | string

    specify a different storage namespace prefix from the default of 'graphiql'

ExecutionResultPayload

ExecutionResultPayload: { data: IntrospectionQuery; errors?: Array<any> } | { data?: any; errors?: Array<any> } | { data?: any; errors?: Array<any>; hasNext: boolean } | { data?: any; errors?: any[]; hasNext: boolean; path: (string | number)[] }

Fetcher

Fetcher: (graphQLParams: FetcherParams, opts?: FetcherOpts) => FetcherReturnType

Type declaration

FetcherOpts

FetcherOpts: { documentAST?: DocumentNode; headers?: undefined | {} }

Type declaration

  • Optional documentAST?: DocumentNode
  • Optional headers?: undefined | {}

FetcherParams

FetcherParams: { operationName?: string | null; query: string; variables?: any }

Type declaration

  • Optional operationName?: string | null
  • query: string
  • Optional variables?: any

FetcherResult

FetcherResult: ExecutionResult | { data: IntrospectionQuery }

FetcherResultPayload

FetcherResultPayload: ExecutionResultPayload

FetcherReturnType

FetcherReturnType: MaybePromise<SyncExecutionResult>

GetDefaultFieldNamesFn

GetDefaultFieldNamesFn: (type: GraphQLType) => string[]

Type declaration

    • (type: GraphQLType): string[]
    • Parameters

      • type: GraphQLType

      Returns string[]

MaybePromise

MaybePromise<T>: T | Promise<T>

Type parameters

  • T

Observable

Observable<T>: { subscribe: any }

Type parameters

  • T

Type declaration

  • subscribe: function
    • subscribe(opts: { complete: () => void; error: (error: any) => void; next: (value: T) => void }): Unsubscribable
    • subscribe(next: (value: T) => void, error: null | undefined, complete: () => void): Unsubscribable
    • subscribe(next?: undefined | ((value: T) => void), error?: undefined | ((error: any) => void), complete?: undefined | (() => void)): Unsubscribable

QueryStoreItem

QueryStoreItem: { favorite?: undefined | false | true; headers?: undefined | string; label?: undefined | string; operationName?: undefined | string; query?: undefined | string; variables?: undefined | string }

Type declaration

  • Optional favorite?: undefined | false | true
  • Optional headers?: undefined | string
  • Optional label?: undefined | string
  • Optional operationName?: undefined | string
  • Optional query?: undefined | string
  • Optional variables?: undefined | string

Storage

Storage: { length: number; clear: any; getItem: any; removeItem: any; setItem: any }

This describes the attributes and methods that a store has to support in order to be used with GraphiQL. It closely resembles the localStorage API as it is the default storage used in GraphiQL.

Type declaration

  • length: number

    The number of items that are currently stored.

  • clear: function
    • clear(): void
  • getItem: function
    • getItem(key: string): string | null
    • Retrieve an item from the store by its key.

      Parameters

      • key: string

        The key of the item to retrieve.

      Returns string | null

      The stored value for the given key if it exists, null otherwise.

  • removeItem: function
    • removeItem(key: string): void
    • Remove the value for a given key from the store. If there is no value for the given key this method does nothing.

      Parameters

      • key: string

        The key to remove the value from the store.

      Returns void

  • setItem: function
    • setItem(key: string, value: string): void
    • Add a value to the store for a given key. If there already exists a value for the given key, this method will override the value.

      Parameters

      • key: string

        The key to store the value for.

      • value: string

        The value to store.

      Returns void

SyncExecutionResult

SyncExecutionResult: ExecutionResult | Observable<ExecutionResult> | AsyncIterable<ExecutionResult>

SyncFetcherResult

SyncFetcherResult: SyncExecutionResult

Unsubscribable

Unsubscribable: { unsubscribe: () => void }

Type declaration

  • unsubscribe: () => void
      • (): void
      • Returns void

Functions

createGraphiQLFetcher

Const createLegacyWebsocketsFetcher

  • createLegacyWebsocketsFetcher(legacyWsClient: { request: (params: FetcherParams) => unknown }): (Anonymous function)

createLocalStorage

  • createLocalStorage(__namedParameters: { namespace: undefined | string }): Storage

Const createMultipartFetcher

Const createSimpleFetcher

Const createWebsocketsFetcherFromClient

  • createWebsocketsFetcherFromClient(wsClient: Client): (Anonymous function)

Const createWebsocketsFetcherFromUrl

  • createWebsocketsFetcherFromUrl(url: string, connectionParams?: ClientOptions["connectionParams"]): undefined | (Anonymous function)

fetcherReturnToPromise

fillLeafs

  • fillLeafs(schema?: GraphQLSchema | null, docString?: undefined | string, getDefaultFieldNames?: GetDefaultFieldNamesFn): { insertions: Insertion[]; result: undefined | string }
  • Given a document string which may not be valid due to terminal fields not representing leaf values (Spec Section: "Leaf Field Selections"), and a function which provides reasonable default field names for a given type, this function will attempt to produce a schema which is valid after filling in selection sets for the invalid fields.

    Note that there is no guarantee that the result will be a valid query, this utility represents a "best effort" which may be useful within IDE tools.

    Parameters

    • Optional schema: GraphQLSchema | null
    • Optional docString: undefined | string
    • Optional getDefaultFieldNames: GetDefaultFieldNamesFn

    Returns { insertions: Insertion[]; result: undefined | string }

    • insertions: Insertion[]
    • result: undefined | string

formatError

  • formatError(error: unknown): string

formatResult

  • formatResult(result: any): string

getSelectedOperationName

  • getSelectedOperationName(prevOperations?: OperationDefinitionNode[] | undefined, prevSelectedOperationName?: undefined | string, operations?: OperationDefinitionNode[]): undefined | string
  • Provided optional previous operations and selected name, and a next list of operations, determine what the next selected operation should be.

    Parameters

    • Optional prevOperations: OperationDefinitionNode[] | undefined
    • Optional prevSelectedOperationName: undefined | string
    • Optional operations: OperationDefinitionNode[]

    Returns undefined | string

Const getWsFetcher

isAsyncIterable

  • isAsyncIterable(input: unknown): input is AsyncIterable<unknown>

isObservable

  • isObservable<T>(value: any): value is Observable<T>

isPromise

  • isPromise<T>(value: Promise<T> | any): value is Promise<T>

Const isSubscriptionWithName

  • isSubscriptionWithName(document: DocumentNode, name: string | undefined): boolean

mergeAst

  • mergeAst(documentAST: DocumentNode, schema?: GraphQLSchema | null): DocumentNode

Generated using TypeDoc