UNPKG

@pothos/plugin-sub-graph

Version:

A Pothos plugin for creating multiple variants or sub-selections of the same graph

60 lines (59 loc) 3.39 kB
import type { FieldNullability, FieldRequiredness, InputFieldMap, InputShapeFromTypeParam, InputType, InterfaceParam, RootName, SchemaTypes, TypeParam } from '@pothos/core'; import type { GraphQLNamedType } from 'graphql'; import type { PothosSubGraphPlugin } from './index.js'; declare global { export namespace PothosSchemaTypes { interface BaseTypeOptions<Types extends SchemaTypes = SchemaTypes> { subGraphs?: Types["SubGraphs"][]; } interface BuildSchemaOptions<Types extends SchemaTypes> { subGraph?: Types["SubGraphs"] | Types["SubGraphs"][] | { all: Types["SubGraphs"][]; }; } interface ObjectTypeOptions<Types extends SchemaTypes = SchemaTypes, Shape = unknown> extends BaseTypeOptions<Types> { defaultSubGraphsForFields?: Types["SubGraphs"][]; } interface RootTypeOptions<Types extends SchemaTypes, Type extends RootName> extends BaseTypeOptions<Types> { defaultSubGraphsForFields?: Types["SubGraphs"][]; } interface InterfaceTypeOptions<Types extends SchemaTypes = SchemaTypes, Shape = unknown, Interfaces extends InterfaceParam<Types>[] = InterfaceParam<Types>[]> extends BaseTypeOptions<Types> { defaultSubGraphsForFields?: Types["SubGraphs"][]; } interface FieldOptions<Types extends SchemaTypes = SchemaTypes, ParentShape = unknown, Type extends TypeParam<Types> = TypeParam<Types>, Nullable extends FieldNullability<Type> = FieldNullability<Type>, Args extends InputFieldMap = InputFieldMap, ResolveShape = unknown, ResolveReturnShape = unknown> { subGraphs?: Types["SubGraphs"][]; } interface ArgFieldOptions<Types extends SchemaTypes = SchemaTypes, Type extends InputType<Types> | [ InputType<Types> ] = InputType<Types> | [ InputType<Types> ], Req extends FieldRequiredness<Type> = FieldRequiredness<Type>> extends InputFieldOptions<Types, Type, Req> { subGraphs?: undefined extends InputShapeFromTypeParam<Types, Type, Req> ? Types["SubGraphs"][] : never; } interface InputObjectFieldOptions<Types extends SchemaTypes = SchemaTypes, Type extends InputType<Types> | [ InputType<Types> ] = InputType<Types> | [ InputType<Types> ], Req extends FieldRequiredness<Type> = FieldRequiredness<Type>> extends InputFieldOptions<Types, Type, Req> { subGraphs?: undefined extends InputShapeFromTypeParam<Types, Type, Req> ? Types["SubGraphs"][] : never; } interface Plugins<Types extends SchemaTypes> { subGraph: PothosSubGraphPlugin<Types>; } interface SchemaBuilderOptions<Types extends SchemaTypes> { subGraphs?: { defaultForTypes?: Types["SubGraphs"][]; defaultForFields?: Types["SubGraphs"][]; fieldsInheritFromTypes?: boolean; explicitlyIncludeType?: (type: GraphQLNamedType, subGraphs: Types["SubGraphs"][]) => boolean; }; } interface UserSchemaTypes { SubGraphs: string; } interface ExtendDefaultTypes<PartialTypes extends Partial<UserSchemaTypes>> { SubGraphs: PartialTypes["SubGraphs"] & string; } } } //# sourceMappingURL=global-types.d.ts.map