@pothos/core
Version:
Pothos (formerly GiraphQL) is a plugin based schema builder for creating code-first GraphQL schemas in typescript
88 lines (87 loc) • 5.56 kB
TypeScript
import type { GraphQLFieldResolver, GraphQLIsTypeOfFn, GraphQLSchema, GraphQLTypeResolver } from 'graphql';
import type { BuildCache } from '../build-cache.js';
import type { PothosEnumValueConfig, PothosInputFieldConfig, PothosInterfaceTypeConfig, PothosObjectTypeConfig, PothosOutputFieldConfig, PothosTypeConfig, PothosUnionTypeConfig, SchemaTypes } from '../types/index.js';
export declare class BasePlugin<Types extends SchemaTypes, T extends object = object> {
name: never;
builder: PothosSchemaTypes.SchemaBuilder<Types>;
buildCache: BuildCache<Types>;
options: PothosSchemaTypes.BuildSchemaOptions<Types>;
private requestDataMap;
constructor(buildCache: BuildCache<Types>, name: keyof PothosSchemaTypes.Plugins<Types>);
/**
* Called for each type defined with the SchemaBuilder
* @param {PothosTypeConfig} typeConfig - Config object describing the added type
* @return {PothosTypeConfig} Original or updated `typeConfig`
*/
onTypeConfig(typeConfig: PothosTypeConfig): PothosTypeConfig;
/**
* Called for each field on an Object or Interface type
* @param {PothosOutputFieldConfig} fieldConfig - Config object describing the added field
* @return {PothosOutputFieldConfig} Original or updated `fieldConfig`
*/
onOutputFieldConfig(fieldConfig: PothosOutputFieldConfig<Types>): PothosOutputFieldConfig<Types> | null;
/**
* Called for each argument or field on an Input object defined in your schema
* @param {PothosInputFieldConfig} fieldConfig - Config object describing the added field
* @return {PothosInputFieldConfig} Original or updated `fieldConfig`
*/
onInputFieldConfig(fieldConfig: PothosInputFieldConfig<Types>): PothosInputFieldConfig<Types> | null;
/**
* Called for each Enum value defined in your schema
* @param {PothosEnumValueConfig} valueConfig - Config object describing the enum value
* @return {PothosEnumValueConfig} Original or updated `valueConfig`
*/
onEnumValueConfig(valueConfig: PothosEnumValueConfig<Types>): PothosEnumValueConfig<Types> | null;
/**
* Called before builder.toSchema() schema is called
*/
beforeBuild(): void;
/**
* Called after all fields and types have been built during `builder.toSchema()`
* @param {GraphQLSchema} schema - the generated schema
* @return {PothosEnumValueConfig} Original or updated `schema`
*/
afterBuild(schema: GraphQLSchema): GraphQLSchema;
/**
* Called with the resolver for each field in the schema
* @param {GraphQLFieldResolver} resolve - the resolve function
* @param {PothosOutputFieldConfig} fieldConfig - the config object for the field associated with this resolve function
* @return {GraphQLFieldResolver} - Either the original, or a new resolver function to use for this field
*/
wrapResolve(resolver: GraphQLFieldResolver<unknown, Types["Context"], object>, _fieldConfig: PothosOutputFieldConfig<Types>): GraphQLFieldResolver<unknown, Types["Context"], object>;
/**
* Called with the subscribe for each field on the Subscription type
* @param {GraphQLFieldResolver} subscribe - the subscribe function
* @param {PothosOutputFieldConfig} fieldConfig - the config object for the field associated with this subscribe function
* @return {GraphQLFieldResolver} - Either the original, or a new subscribe function to use for this field
*/
wrapSubscribe(subscribe: GraphQLFieldResolver<unknown, Types["Context"], object> | undefined, _fieldConfig: PothosOutputFieldConfig<Types>): GraphQLFieldResolver<unknown, Types["Context"], object> | undefined;
/**
* Called with the resolveType for each Interface or Union type
* @param {GraphQLTypeResolver} resolveType - the resolveType function
* @param {PothosInterfaceTypeConfig | PothosUnionTypeConfig} typeConfig - the config object for the Interface or Union type
* @return {GraphQLTypeResolver} - Either the original, or a new resolveType function to use for this field
*/
wrapResolveType(resolveType: GraphQLTypeResolver<unknown, Types["Context"]>, _typeConfig: PothosInterfaceTypeConfig | PothosUnionTypeConfig): GraphQLTypeResolver<unknown, Types["Context"]>;
/**
* Called with the isTypeOf for each Object type
* @param {GraphQLTypeResolver} resolveType - the resolveType function
* @param {PothosObjectTypeConfig} typeConfig - the config object for the Interface or Union type
* @return {GraphQLTypeResolver} - Either the original, or a new resolveType function to use for this field
*/
wrapIsTypeOf(isTypeOf: GraphQLIsTypeOfFn<unknown, Types["Context"]> | undefined, _typeConfig: PothosObjectTypeConfig): GraphQLIsTypeOfFn<unknown, Types["Context"]> | undefined;
protected runUnique<R>(key: unknown, cb: () => R): R;
/**
* Creates a data object unique to the current request for use by this plugin
* @param {Types['Context']} context - the context object for the current request
* @return {object} - The data object for the current request
*/
protected createRequestData(_context: Types["Context"]): T;
/**
* Returns a data object for the current request. requires `createRequestData` to be implemented
* @param {Types['Context']} context - the context object for the current request
* @return {object} - The data object for the current request
*/
protected requestData(context: Types["Context"]): T;
}
//# sourceMappingURL=plugin.d.ts.map