-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.gql
221 lines (178 loc) · 3.76 KB
/
schema.gql
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
scalar Date
type Query {
searchBooks(query: String, paginate: PaginationInput): PaginatedBooks!
search(
query: String
maxPrice: Int
minPrice: Int
paginate: PaginationInput
): PaginatedListings!
top(paginate: PaginationInput): PaginatedListings!
me: SystemUser
listing(id: ID!): Listing
book(id: ID!): Book
users: [User!]!
schools: [School!]!
sessions: [Session!]!
searchGoogle(query: String!): [GoogleBook!]
googleBook(id: ID!): GoogleBook!
thread(id: ID!): Thread
}
type Mutation {
register(email: String!, password: String!): User!
resendConfirmEmail(email: String!): Boolean!
confirm(code: String!): Boolean!
login(email: String!, password: String!, type: SystemUserType!): SystemUser!
logout: Boolean!
requestResetPassword(email: String!): Boolean!
resetPassword(token: String!, password: String!): Boolean!
setSchoolName(id: ID!, name: String!): School!
createListing(listing: ListingInput!): Listing!
deleteListing(id: ID!): Boolean
saveListing(listingId: ID!, saved: Boolean!): Listing!
sellListing(listingId: ID!, price: Int!): Listing!
setPrice(listingId: ID!, price: Int!): Listing!
toggleUserTrackable: User!
startThread(listingId: ID!): Thread!
sendMessage(threadId: ID!, content: String!): Message!
}
type Subscription {
newMessage: Message
}
enum SystemUserType {
ADMIN
USER
}
enum ListingCondition {
NEW
LIKE_NEW
VERY_GOOD
GOOD
ACCEPTABLE
}
input PaginationInput {
limit: Int
offset: Int
}
type PaginatedListings {
items: [Listing!]!
totalCount: Int!
}
type PaginatedBooks {
items: [Book!]!
totalCount: Int!
}
type User {
id: ID!
email: String!
name: String
photo: String
isTrackable: Boolean!
listings: [Listing!]!
recent: [Listing!]!
saved(paginate: PaginationInput): PaginatedListings!
confirmedAt: Date
schoolName: String @deprecated(reason: "use school.name instead")
school: School!
threads(paginate: PaginationInput): PaginatedThreads!
}
input UserInput {
name: String!
}
type Admin {
id: ID!
email: String!
}
union SystemUser = Admin | User
type Listing {
id: ID!
createdAt: Date!
price: Int!
description: String!
book: Book!
user: User
# references user.school without revealing much user information
school: School!
saved: Boolean
soldAt: Date
soldPrice: Int
condition: ListingCondition
}
input ListingInput {
googleId: String!
price: Int!
description: String!
coverIndex: Int # optional for backwards compat reasons
condition: ListingCondition # optional for backwards compat reasons
}
type Book {
id: String!
etag: String
googleId: String
authors: [String!]!
isbn: [String!]!
publishedAt: Date
title: String!
subTitle: String
thumbnail: String
listings(paginate: PaginationInput): PaginatedListings!
}
# book but without id
type GoogleBook {
etag: String
googleId: String!
authors: [String!]!
isbn: [String!]!
publishedAt: Date
title: String!
subTitle: String
thumbnail: String
possibleCovers: [String!]!
}
type School {
id: ID!
# createdAt: Date!
# updatedAt: Date!
name: String!
# only accessible to administrators
domain: String!
}
type Session {
id: ID!
expiresAt: Date!
user: SystemUser!
}
# chat system
type Thread {
id: ID!
# TODO: these may be unnsessary
sellerId: ID!
seller: User!
buyerId: ID!
buyer: User!
otherId: ID!
other: User!
listingId: ID!
listing: Listing!
lastMessage: Message
messages(paginate: PaginationInput): PaginatedMessages!
}
type PaginatedThreads {
items: [Thread!]!
totalCount: Int!
}
type Message {
id: ID!
createdAt: Date!
threadId: ID!
thread: Thread!
fromId: ID!
from: User!
toId: ID!
to: User!
content: String!
}
type PaginatedMessages {
items: [Message!]!
totalCount: Int!
}