Options
All
  • Public
  • Public/Protected
  • All
Menu

graphql-clientgen

Index

Type aliases

Config

Config: object

Type declaration

Context

Context: object

Type declaration

  • action: Actions
  • config: FetcherConfig<V, R>
  • Optional errors?: string[]
  • Optional querySuffix?: undefined | string
  • requestConfig: RequestInit
  • Optional result?: R | null
  • variables: V

Dict

Dict: object

Type declaration

  • [key: string]: T

FetcherConfig

FetcherConfig: object

Type declaration

  • Optional appendToFragment?: undefined | string
  • Optional cache?: undefined | false | true
  • Optional entityName?: undefined | string
  • Optional fragment?: undefined | string
  • Optional headers?: undefined | object
  • kind: OpKind
  • Optional middleware?: Middleware<V, R>[] | Middleware<V, R>
  • query: string
  • Optional querySuffix?: undefined | string
  • Optional schemaKey?: undefined | string
  • url: string

Field

Field: GraphQLField<any, any>

GraphQLClientConfig

GraphQLClientConfig: object

Type declaration

HookState

HookState: object

Type declaration

  • Optional context?: undefined | object
  • Optional error?: string | null
  • loading: boolean
  • resolved: boolean
  • Optional result?: undefined | T

Method

Method: function

Type declaration

    • (variables: Variables, config?: Config): Promise<Context<Variables, ReturnType | undefined | null>>
    • Parameters

      • variables: Variables
      • Optional config: Config

      Returns Promise<Context<Variables, ReturnType | undefined | null>>

MethodsDict

MethodsDict: object

Type declaration

MethodsInfo

MethodsInfo: object

Type declaration

Middleware

Middleware: function

Type declaration

MiddlewareWrapper

MiddlewareWrapper: function

Type declaration

    • (requestSignature: string, schemaKey: string): Middleware<any>
    • Parameters

      • requestSignature: string
      • schemaKey: string

      Returns Middleware<any>

Options

Options: object

Type declaration

Props

Props: object

Type declaration

QueryItem

QueryItem: object

Type declaration

  • argumentsDict: Dict
  • entityName: string
  • field: Field
  • opName: string
  • opType: string
  • query: string
  • queryBody: string
  • queryFooter: string
  • queryHeader: string
  • queryParts: [string, string, string]
  • schemaKey: string
  • Optional varsToTypesStr?: undefined | string

QueueItem

QueueItem: object

Type declaration

Resolver

Resolver: function

Type declaration

ResolverStoreItem

ResolverStoreItem: object

Type declaration

  • argsTSName: string
  • entityName: string
  • field: GraphQLField<any, any>
  • isList: boolean
  • isMutation: boolean
  • isNonNull: boolean
  • isQuery: boolean
  • isSubscription: boolean
  • kind: string
  • returnTSName: string
  • schemaKey: string
  • type: GraphQLObjectType

ResolversStore

ResolversStore: Map<string, ResolverStoreItem>

Return

Return: object | object

SameCacheKeyListener

SameCacheKeyListener: function

Type declaration

    • Parameters

      Returns any

Store

Store: object

Type declaration

StoreListener

StoreListener: function

Type declaration

    • (value: StoreState, requestSignature: string, schemaKey: string): any
    • Parameters

      • value: StoreState
      • requestSignature: string
      • schemaKey: string

      Returns any

StoreState

StoreState: object

Type declaration

  • context: Context<V, Result>
  • error: undefined | string
  • isOptimistic: boolean
  • listeners: SameCacheKeyListener[]
  • loading: boolean
  • resolved: boolean
  • result: undefined | Result

Unpacked

Unpacked: Unpacked<T>

UseClient

UseClient: function

Type declaration

    • <A, K, M, R>(methodName: K, initialFetchConfig?: undefined | object): [HookState<R, A["variables"]>, function, GraphQLStore]
    • Type parameters

      • A: object

      • K: keyof Methods

      • M: function

      • R

      Parameters

      • methodName: K
      • Optional initialFetchConfig: undefined | object

      Returns [HookState<R, A["variables"]>, function, GraphQLStore]

Variables

Const GraphQLStoreContext

GraphQLStoreContext: Context<GraphQLStore> = React.createContext({} as GraphQLStore)

Const basePath

basePath: string = path.resolve(__dirname, '../../template')

Const cli

cli: Result = meow(`Usage:$ graphql-clientgen ENDPOINT_URL destination-folder/Fetch and print the GraphQL Client from a GraphQL HTTP endpoint.Options:--header, -h Add a custom header (ex. 'X-API-KEY=ABC123'), can be used multiple times--method Use method (GET,POST, PUT, DELETE)`,{flags: {header: {type: 'string',alias: 'h'},method: {type: 'string',default: 'POST'},output: {type: 'string'}}})

Functions

addTabs

  • addTabs(str?: string, n?: number): string

Const applyMiddleware

compose

ensureArray

  • ensureArray(el: any): any[]

expandFields

  • expandFields(config: object): object[]
  • Parameters

    • config: object
      • Optional depthLimit?: undefined | number
      • Optional includeDeprecatedFields?: undefined | false | true
      • schema: GraphQLSchema

    Returns object[]

generateQuery

  • generateQuery(config: object): Map<string, object>
  • Parameters

    • config: object
      • Optional depthLimit?: undefined | number
      • Optional includeDeprecatedFields?: undefined | false | true
      • schema: GraphQLSchema

    Returns Map<string, object>

Const getClientBase

  • getClientBase(): Promise<object>

getHeadersFromInput

  • getHeadersFromInput(cli: Result): object

getRemoteSchema

  • getRemoteSchema(endpoint: string, options?: FetchOptions): Promise<object | object>

getResolversHelper

  • getResolversHelper(schema: GraphQLSchema): Map<string, object>

main

  • main(cli: Result): Promise<void>
  • Main

    Parameters

    • cli: Result

    Returns Promise<void>

mountClient

  • mountClient(schema: GraphQLSchema, clientBase: string): object
  • Parameters

    • schema: GraphQLSchema
    • clientBase: string

    Returns object

    • clientBody: string
    • prependBody: string
    • query: string

parseContextAction

  • parseContextAction(ctx: Context): object
  • state actions are actions that are not fetch actions, that is, actions that are not generic for all queries on a batch -

    only initFetch and completeFetch are not state actions: initFetch is called before fetch and can be used to change fetch config, like headers - completeFetch is called before distribute results by the queries in the current batch that originated the fetch request

    Parameters

    Returns object

    • isComplete: boolean
    • isStateAction: boolean

parseContextInfo

  • parseContextInfo(ctx: Context): object
  • Parse info from Middleware context

    Parameters

    Returns object

    • canCache: boolean
    • error: undefined | string
    • isActionAbort: boolean
    • isActionComplete: boolean
    • isActionWillQueue: boolean
    • isComplete: boolean
    • isMutation: boolean
    • isQuery: boolean
    • isStateAction: boolean
    • result: any

parseFragmentConfig

  • parseFragmentConfig(fragment: string, config?: any): string

prettify

  • prettify(filePath: string, content: string): Promise<string>
  • Parameters

    • filePath: string
    • content: string

    Returns Promise<string>

Const printClient

  • printClient(schema: GraphQLSchema): Promise<object>

printFromEndpoint

  • printFromEndpoint(url: string, options?: Options): Promise<Return>

Const printJSON

  • printJSON(obj: any): void

Const storeStateToHookState

  • storeStateToHookState(state?: StoreState, isLoadingIfNotCached?: undefined | false | true): HookState<any, any>

Const useClient

  • useClient(methodName: K, initialFetchConfig: undefined | object): [object, fetcher, GraphQLStore]

useGraphQLStore

  • useGraphQLStore(methodName: keyof Methods): object
  • Parameters

    • methodName: keyof Methods

    Returns object

    • method: function
        • (variables: Variables, config?: Config): Promise<Context<Variables, ReturnType | undefined | null>>
        • Parameters

          • variables: Variables
          • Optional config: Config

          Returns Promise<Context<Variables, ReturnType | undefined | null>>

    • store: GraphQLStore

Object literals

Const EXTENSION_TO_PARSER

EXTENSION_TO_PARSER: object

css

css: string = "postcss"

flow

flow: string = "flow"

gql

gql: string = "graphql"

graphql

graphql: string = "graphql"

graphqls

graphqls: string = "graphql"

js

js: string = "babylon"

js.flow

js.flow: string = "flow"

json

json: string = "json"

jsx

jsx: string = "babylon"

less

less: string = "postcss"

markdown

markdown: string = "markdown"

md

md: string = "markdown"

scss

scss: string = "postcss"

stylus

stylus: string = "postcss"

ts

ts: string = "typescript"

tsx

tsx: string = "typescript"

Generated using TypeDoc