@pothos/plugin-directives
Version:
Directive plugin for Pothos, enables using graphql-tools based directives with Pothos
36 lines (31 loc) • 1 kB
text/typescript
import type { SchemaTypes } from '@pothos/core';
export type DirectiveLocation =
| 'ARGUMENT_DEFINITION'
| 'ENUM_VALUE'
| 'ENUM'
| 'FIELD_DEFINITION'
| 'INPUT_FIELD_DEFINITION'
| 'INPUT_OBJECT'
| 'INTERFACE'
| 'OBJECT'
| 'SCALAR'
| 'SCHEMA'
| 'UNION';
export type DirectiveList = { name: string; args?: object }[];
export type DirectivesFor<Types extends SchemaTypes, Location extends DirectiveLocation> = {
[K in keyof Types['Directives']]: Location extends Types['Directives'][K]['locations']
? K
: never;
}[keyof Types['Directives']];
export type Directives<Types extends SchemaTypes, Location extends DirectiveLocation> =
| {
[K in keyof Types['Directives']]: Types['Directives'][K]['locations'] extends Location
? {
name: K;
args: Types['Directives'][K]['args'];
}
: never;
}[keyof Types['Directives']][]
| {
[K in DirectivesFor<Types, Location>]?: Types['Directives'][K]['args'] & {};
};