Options
All
  • Public
  • Public/Protected
  • All
Menu

Package graphiql-toolkit

Changelog | API Docs | NPM | Discord

@graphiql/toolkit

General purpose library as a dependency of GraphiQL.

A core dependency of the GraphiQL 2.0.0 initiative.

Docs

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

Todo

  • Begin porting common type definitions used by GraphiQL and it's dependencies
  • createGraphiQLFetcher utility for an easier fetcher
  • Migrate over general purpose graphiql/src/utilities
  • Utility to generate json schema spec from getQueryFacts for monaco, vscode, etc

Index

References

CreateFetcherOptions

Re-exports CreateFetcherOptions

CreateFetcherOptions

Re-exports CreateFetcherOptions

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

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

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?: {}; shouldPersistHeaders?: boolean }

Type declaration

  • Optional documentAST?: DocumentNode
  • Optional headers?: {}
    • [key: string]: any
  • Optional shouldPersistHeaders?: boolean
    deprecated

    This property will be removed in the next major version of graphiql, it just echoes back the value passed as prop to the GraphiQL component with a default value of false

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?: (value: T) => void, error?: (error: any) => void, complete?: () => void): Unsubscribable
    • Parameters

      • opts: { complete: () => void; error: (error: any) => void; next: (value: T) => void }
        • complete: () => void
            • (): void
            • Returns void

        • error: (error: any) => void
            • (error: any): void
            • Parameters

              • error: any

              Returns void

        • next: (value: T) => void
            • (value: T): void
            • Parameters

              • value: T

              Returns void

      Returns Unsubscribable

    • Parameters

      • next: (value: T) => void
          • (value: T): void
          • Parameters

            • value: T

            Returns void

      • error: null | undefined
      • complete: () => void
          • (): void
          • Returns void

      Returns Unsubscribable

    • Parameters

      • Optional next: (value: T) => void
          • (value: T): void
          • Parameters

            • value: T

            Returns void

      • Optional error: (error: any) => void
          • (error: any): void
          • Parameters

            • error: any

            Returns void

      • Optional complete: () => void
          • (): void
          • Returns void

      Returns Unsubscribable

QueryStoreItem

QueryStoreItem: { favorite?: boolean; headers?: string; label?: string; operationName?: string; query?: string; variables?: string }

Type declaration

  • Optional favorite?: boolean
  • Optional headers?: string
  • Optional label?: string
  • Optional operationName?: string
  • Optional query?: string
  • Optional variables?: string

Storage

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

Type declaration

  • length: number
  • getItem: function
    • getItem(key: string): string | null
    • Parameters

      • key: string

      Returns string | null

  • removeItem: function
    • removeItem(key: string): void
    • Parameters

      • key: string

      Returns void

  • setItem: function
    • setItem(key: string, value: string): void
    • Parameters

      • key: string
      • value: string

      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

  • build a GraphiQL fetcher that is:

    • backwards compatible
    • optionally supports graphql-ws or `

    Parameters

    Returns Fetcher

Const createLegacyWebsocketsFetcher

  • createLegacyWebsocketsFetcher(legacyWsClient: { request: (params: FetcherParams) => unknown }): (Anonymous function)
  • Allow legacy websockets protocol client, but no definitions for it, as the library is deprecated and has security issues

    Parameters

    Returns (Anonymous function)

Const createMultipartFetcher

  • create a fetcher with the IncrementalDelivery HTTP/S spec for @stream and @defer support using fetch-multipart-graphql

    Parameters

    Returns Fetcher

Const createSimpleFetcher

  • create a simple HTTP/S fetcher using a fetch implementation where multipart is not needed

    Parameters

    Returns Fetcher

Const createWebsocketsFetcherFromClient

  • createWebsocketsFetcherFromClient(wsClient: Client): (Anonymous function)
  • Create ws/s fetcher using provided wsClient implementation

    Parameters

    • wsClient: Client

    Returns (Anonymous function)

Const createWebsocketsFetcherFromUrl

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

    • url: string
    • Optional connectionParams: ClientOptions["connectionParams"]

    Returns (Anonymous function)

fetcherReturnToPromise

fillLeafs

  • fillLeafs(schema?: GraphQLSchema | null, docString?: string, getDefaultFieldNames?: GetDefaultFieldNamesFn): { insertions: Insertion[]; result: 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: string
    • Optional getDefaultFieldNames: GetDefaultFieldNamesFn

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

    • insertions: Insertion[]
    • result: string

formatError

  • formatError(error: unknown): string
  • Parameters

    • error: unknown

    Returns string

formatResult

  • formatResult(result: any): string
  • Parameters

    • result: any

    Returns string

getSelectedOperationName

  • getSelectedOperationName(prevOperations?: OperationDefinitionNode[] | undefined, prevSelectedOperationName?: string, operations?: OperationDefinitionNode[]): 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: string
    • Optional operations: OperationDefinitionNode[]

    Returns string

Const getWsFetcher

  • If wsClient or legacyClient are provided, then subscriptionUrl is overridden.

    Parameters

    Returns (Anonymous function)

isAsyncIterable

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

    • input: unknown

    Returns input is AsyncIterable<unknown>

isObservable

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

    • T

    Parameters

    • value: any

    Returns value is Observable<T>

isPromise

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

    • T

    Parameters

    • value: Promise<T> | any

    Returns value is Promise<T>

Const isSubscriptionWithName

  • isSubscriptionWithName(document: DocumentNode, name: string | undefined): boolean
  • Returns true if the name matches a subscription in the AST

    Parameters

    • document: DocumentNode
    • name: string | undefined

      the operation name to lookup

    Returns boolean

mergeAst

  • mergeAst(documentAST: DocumentNode, schema?: GraphQLSchema | null): DocumentNode
  • Given a document AST, inline all named fragment definitions.

    Parameters

    • documentAST: DocumentNode
    • Optional schema: GraphQLSchema | null

    Returns DocumentNode

Generated using TypeDoc