-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtypes.ts
47 lines (41 loc) · 1002 Bytes
/
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
import type { GraphQLArgs, GraphQLSchema } from './deps.ts'
import type { RenderPageOptions } from './graphiql/render.ts'
/**
* gql options
*/
export interface GQLOptions<Context = any, Req extends GQLRequest = GQLRequest>
extends Omit<GraphQLArgs, 'source'> {
schema: GraphQLSchema
context?: (val: Req) => Context | Promise<Context>
/**
* GraphQL playground
*/
graphiql?: boolean
/**
* Custom headers for responses
*/
headers?: HeadersInit
/**
* Custom options for GraphQL Playground
*/
playgroundOptions?: Omit<RenderPageOptions, 'endpoint'>
}
interface Params {
variables?: Record<string, unknown>
operationName?: string
}
interface QueryParams extends Params {
query: string
mutation?: never
}
interface MutationParams extends Params {
mutation: string
query?: never
}
export type GraphQLParams = QueryParams | MutationParams
export type GQLRequest = {
url: string
method: string
headers: Headers
json: () => Promise<GraphQLParams>
}