/
typeDefs.ts
67 lines (59 loc) · 1.56 KB
/
typeDefs.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
import { RESTDataSource } from 'apollo-datasource-rest'
import { DataSource } from 'apollo-datasource'
export interface Mission {
name: string
missionPatchSmall: string
missionPatchLarge: string
}
export interface Rocket {
id: number
name: string
type: string
}
export interface Launch {
id: number
cursor: string
site: string
mission: Mission
rocket: Rocket
}
export interface DBUser {
id: string
createdAt: Date
updatedAt: Date
email: string
token: string
}
export interface DBTrip {
id: number
createdAt: Date
updatedAt: Date
launchId: number
userId: number
}
export interface LaunchApi extends RESTDataSource {
getAllLaunches(): Promise<Launch[]>
getLaunchById(opts: { launchId: string }): Promise<Launch>
getLaunchesByIds(opts: { launchIds: string[] }): Promise<Launch[]>
}
export interface UserApi extends DataSource {
/**
* User can be called with an argument that includes email, but it doesn't have to be. If the user is
* already on the context, it will use that user instead
*/
findOrCreateUser(obj?: { email?: string | null }): Promise<DBUser | null>
bookTrips(obj: { launchIds: string[] }): Promise<DBTrip[]>
bookTrip(obj: { launchId: string }): Promise<DBTrip | false>
cancelTrip(obj: { launchId: string }): Promise<void>
getLaunchIdsByUser(): Promise<string[]>
isBookedOnLaunch(obj: { launchId: string }): boolean
}
export interface Utils {
paginateResults<T>(opts: {
after?: string | null
pageSize?: number | null
results: T[]
getCursor?: Function
}): T[]
createStore(): {}
}