This repository has been archived by the owner on Jul 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
types.ts
107 lines (98 loc) · 2.97 KB
/
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
import { PrismaClientInput, PrismaSchemaConfig } from 'nexus-prisma/dist/types'
import Express from 'express'
import { Server as HttpServer } from 'http'
export type MaybePromise<T> = Promise<T> | T
export type DatamodelInfo = PrismaSchemaConfig['prisma']['datamodelInfo']
export type InputPrismaConfig = {
/**
* The default exported object generated by `nexus-prisma-generate`
*
* Import it from the output directory generated by `nexus-prisma-generate`
*/
datamodelInfoPath?: string
/**
* Instance of the prisma-client, either passed statically
* or returned from the context defined in your GraphQL server
*
* @default ./.yoga/prisma-client/index.ts
*/
client?: PrismaClientInput
}
export type InputOutputFilesConfig = {
/**
* Path to the generated typings
* @default ./.yoga/nexus.ts
*/
typegenPath?: string
/**
* Path to the generated schema
* @default ./src/schema.graphql
*/
schemaPath?: string
}
export type InputConfig = {
/**
* Path to the resolvers directory.
* **Path has to exist**
* @default ./src/graphql/
*/
resolversPath?: string
/**
* Path to the `context.ts` file to inject a context into your graphql resolvers. **If provided, path has to exist**
* @default ./src/context.ts
*/
contextPath?: string
/**
* Path to the `types.ts` file to override nexus default types **If provided, path has to exist**
* @default ./src/types.ts
*/
typesPath?: string
/**
* Path to the `server.ts` file to eject from default configuration file `yoga.config.ts`.
* When provided, all other configuration properties are ignored and should be configured programatically.
* **If provided, path has to exist**
* @default ./src/server.ts
*/
ejectFilePath?: string
/**
* Path to the `express.ts` file.
* This file gets injected the underlying express instance (to add routes, or middlewares etc...)
* **If provided, path has to exist**
* @default ./src/express.ts
*/
expressPath?: string
/**
* Config for the outputted files (schema, typings ..)
*/
output?: InputOutputFilesConfig
/**
* Config for the prisma integration
*/
prisma?: InputPrismaConfig
}
type RequiredProperty<T extends keyof InputConfig> = Exclude<
Required<Exclude<InputConfig[T], undefined>>,
undefined
>
export type Config = {
resolversPath: RequiredProperty<'resolversPath'>
contextPath?: RequiredProperty<'contextPath'>
ejectFilePath?: RequiredProperty<'ejectFilePath'>
typesPath?: RequiredProperty<'typesPath'>
output: RequiredProperty<'output'>
prisma?: PrismaSchemaConfig['prisma']
expressPath?: RequiredProperty<'expressPath'>
}
export type ConfigWithInfo = {
yogaConfigPath?: string
yogaConfig: Config
projectDir: string
inputConfig: InputConfig
datamodelInfoDir?: string
prismaClientDir?: string
}
export interface Yoga<T = Express.Application, U = HttpServer> {
server: () => MaybePromise<T>
startServer: (params: T) => MaybePromise<U>
stopServer: (params: U) => any
}