UNPKG

@notadd/graphql

Version:

notadd core none dependence

112 lines (106 loc) 4.36 kB
import { InjectionToken } from '@notadd/core'; import { DocumentNode, GraphQLSchema, GraphQLResolveInfo, GraphQLScalarType, GraphQLObjectType, SelectionSetNode, SelectionNode } from 'graphql' import { IFieldResolver, DirectiveResolverFn } from 'graphql-tools'; export const GRAPHQL_PATH = new InjectionToken<string>(`@notadd/graphql GRAPHQL_PATH`) export const GRAPHQL_QUERY = new InjectionToken<string>(`@notadd/graphql GRAPHQL_QUERY`) export const GRAPHQL_DOCUMENT = new InjectionToken<DocumentNode>(`@notadd/graphql GRAPHQL_DOCUMENT`) export const GRAPHQL_SOURCE = new InjectionToken<any>(`@notadd/graphql GRAPHQL_SOURCE`) export const GRAPHQL_SCHEMA = new InjectionToken<Promise<GraphQLSchema>>(`@notadd/graphql GRAPHQL_SCHEMA`) export const GRAPHQL_INFO = new InjectionToken<GraphQLResolveInfo>(`@notadd/graphql GRAPHQL_INFO`) export const GRAPHQL_SUBSCRIPTION_PATH = new InjectionToken<string>(`@notadd/graphql GRAPHQL_SUBSCRIPTION_PATH`) export declare type CursorShape = 'line' | 'block' | 'underline'; export declare type Theme = 'dark' | 'light'; export interface ISettings { 'general.betaUpdates': boolean; 'editor.cursorShape': CursorShape; 'editor.theme': Theme; 'editor.reuseHeaders': boolean; 'tracing.hideTracingResponse': boolean; 'queryPlan.hideQueryPlanResponse'?: boolean; 'editor.fontSize': number; 'editor.fontFamily': string; 'request.credentials': string; } export interface IntrospectionResult { __schema: any; } export interface EditorColours { property: string; comment: string; punctuation: string; keyword: string; def: string; qualifier: string; attribute: string; number: string; string: string; builtin: string; string2: string; variable: string; meta: string; atom: string; ws: string; selection: string; cursorColor: string; editorBackground: string; resultBackground: string; leftDrawerBackground: string; rightDrawerBackground: string; } export interface MiddlewareOptions { endpoint?: string; subscriptionEndpoint?: string; workspaceName?: string; env?: any; config?: any; settings?: ISettings; schema?: IntrospectionResult; tabs?: Tab[]; codeTheme?: EditorColours; } export interface Tab { endpoint: string; query: string; name?: string; variables?: string; responses?: string[]; headers?: { [key: string]: string; }; } export interface RenderPageOptions extends MiddlewareOptions { version?: string; cdnUrl?: string; env?: any; title?: string; faviconUrl?: string | null; } export const GRAPHQL_RENDER_PAGE_OPTIONS = new InjectionToken<RenderPageOptions>(`@notadd/graphql GRAPHQL_RENDER_PAGE_OPTIONS`) export const OBJECT_RESOLVER = new InjectionToken< { path: string; handler: any }[] >(`@notadd/graphql OBJECT_RESOLVER`); export const MUTATION_RESOLVER = new InjectionToken< { path: string; handler: IFieldResolver<any, any, any> }[] >(`@notadd/graphql MUTATION_RESOLVER`); export const SUBSCRIPTION_RESOLVER = new InjectionToken< { path: string; handler: any }[] >(`@notadd/graphql SUBSCRIPTION_RESOLVER`); export const SCALAR_RESOLVER = new InjectionToken<GraphQLScalarType[]>( `@notadd/graphql SCALAR_RESOLVER` ); export const DIRECTIVE_RESOLVER = new InjectionToken< { path: string; handler: DirectiveResolverFn<any, any>; }[] >(`@notadd/graphql DIRECTIVE_RESOLVER`); export const RESOLVER = new InjectionToken<any>(`@notadd/graphql RESOLVER`); export const WS_ERROR = new InjectionToken<(res: Error) => void>(`@notadd/ws WS_ERROR`) export const WS_NEXT = new InjectionToken<(res: any) => void>(`@notadd/ws WS_NEXT`) export const WS_COMPLETE = new InjectionToken<() => void>(`@notadd/ws WS_COMPLETE`) export const GRAPHQL_OBJECT_TYPE = new InjectionToken<GraphQLObjectType>(`@notadd/ws GRAPHQL_OBJECT_TYPE`) export const GRAPHQL_SELECTION_SET = new InjectionToken<SelectionSetNode>(`@notadd/ws GRAPHQL_SELECTION_SET`) export const GRAPHQL_SELECTION = new InjectionToken<SelectionSetNode>(`@notadd/ws GRAPHQL_SELECTION`) export const GRAPHQL_SELECTIONS = new InjectionToken<string[]>(`@notadd/ws GRAPHQL_SELECTIONS`) // 日志所用的钩子 export const UseLoggerAfterMetadataKey = new InjectionToken<any>(`@notadd/logger UseLoggerAfterMetadataKey`)