This repository has been archived by the owner on Nov 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resolver-types.ts
117 lines (100 loc) · 3.23 KB
/
resolver-types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
export type Maybe<T> = T | null;
// ====================================================
// Types
// ====================================================
export interface Event {
readonly expanded: boolean;
}
// ====================================================
// Arguments
// ====================================================
import { GraphQLResolveInfo } from "graphql";
export type Resolver<Result, Parent = {}, TContext = {}, Args = {}> = (
parent: Parent,
args: Args,
context: TContext,
info: GraphQLResolveInfo
) => Promise<Result> | Result;
export interface ISubscriptionResolverObject<Result, Parent, TContext, Args> {
subscribe<R = Result, P = Parent>(
parent: P,
args: Args,
context: TContext,
info: GraphQLResolveInfo
): AsyncIterator<R | Result> | Promise<AsyncIterator<R | Result>>;
resolve?<R = Result, P = Parent>(
parent: P,
args: Args,
context: TContext,
info: GraphQLResolveInfo
): R | Result | Promise<R | Result>;
}
export type SubscriptionResolver<
Result,
Parent = {},
TContext = {},
Args = {}
> =
| ((
...args: any[]
) => ISubscriptionResolverObject<Result, Parent, TContext, Args>)
| ISubscriptionResolverObject<Result, Parent, TContext, Args>;
export type TypeResolveFn<Types, Parent = {}, TContext = {}> = (
parent: Parent,
context: TContext,
info: GraphQLResolveInfo
) => Maybe<Types>;
export type NextResolverFn<T> = () => Promise<T>;
export type DirectiveResolverFn<TResult, TArgs = {}, TContext = {}> = (
next: NextResolverFn<TResult>,
source: any,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => TResult | Promise<TResult>;
export interface EventResolvers<TContext = {}, TypeParent = Event> {
expanded: EventExpandedResolver<boolean, TypeParent, TContext>;
}
export type EventExpandedResolver<
R = boolean,
Parent = Event,
TContext = {}
> = Resolver<R, Parent, TContext>;
/** Directs the executor to skip this field or fragment when the `if` argument is true. */
export type SkipDirectiveResolver<Result> = DirectiveResolverFn<
Result,
SkipDirectiveArgs,
{}
>;
export interface SkipDirectiveArgs {
/** Skipped when true. */
if: boolean;
}
/** Directs the executor to include this field or fragment only when the `if` argument is true. */
export type IncludeDirectiveResolver<Result> = DirectiveResolverFn<
Result,
IncludeDirectiveArgs,
{}
>;
export interface IncludeDirectiveArgs {
/** Included when true. */
if: boolean;
}
/** Marks an element of a GraphQL schema as no longer supported. */
export type DeprecatedDirectiveResolver<Result> = DirectiveResolverFn<
Result,
DeprecatedDirectiveArgs,
{}
>;
export interface DeprecatedDirectiveArgs {
/** Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax (as specified by [CommonMark](https://commonmark.org/). */
reason?: string;
}
export type IResolvers<TContext = {}> = {
Event: EventResolvers<TContext>;
} & { [typeName: string]: never };
export type IDirectiveResolvers<Result> = {
skip: SkipDirectiveResolver<Result>;
include: IncludeDirectiveResolver<Result>;
deprecated: DeprecatedDirectiveResolver<Result>;
} & { [directiveName: string]: never };