-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.graphql
More file actions
197 lines (177 loc) · 5.28 KB
/
schema.graphql
File metadata and controls
197 lines (177 loc) · 5.28 KB
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
"""
A scheduled event. All ticket types (including sold out) are under `tickets`.
"""
type Event {
id: ID!
title: String!
description: String
startsAt: String!
venue: Venue!
tickets: [Ticket!]!
"""Absolute URL of a JPEG image representing this event, served by this backend."""
imageUrl: String!
}
"""
A physical venue where events are held. Referenced by `Event.venue`.
"""
type Venue {
id: ID!
name: String!
"""Absolute URL of a JPEG image representing this venue, served by this backend."""
imageUrl: String!
}
"""
A ticket type for an event. `quantityAvailable` is how many can still be bought (in-memory catalog; decreases when a unit is added to a cart).
"""
type Ticket {
id: ID!
label: String!
priceCents: Int!
currency: String!
quantityAvailable: Int!
}
type Query {
"""
All events in the catalog.
`error` is set on transport-level failure (see server mock rate); `events` is empty when that happens.
"""
events: EventsQueryResult!
"""A single event by id; `event` is null if not found (no error) or on failure with `error` set."""
event(id: ID!): EventQueryResult!
"""
Events whose `title` contains the given text (case-insensitive).
Whitespace around `query` is ignored; an empty or whitespace-only `query` returns no events.
"""
searchEvents(query: String!): SearchEventsQueryResult!
"""
Tickets currently available for purchase (quantity available greater than zero), with parent event id included.
When `query` is omitted, null, or blank (after trim), all such tickets are returned.
Otherwise only events whose `title` contains the text (case-insensitive) are included.
"""
ticketsForPurchase(query: String): TicketsForPurchaseQueryResult!
}
type EventsQueryResult {
events: [Event!]!
error: Error
}
type EventQueryResult {
event: Event
error: Error
}
type SearchEventsQueryResult {
events: [Event!]!
error: Error
}
type TicketsForPurchaseQueryResult {
tickets: [TicketWithEvent!]!
error: Error
}
type TicketWithEvent {
eventId: ID!
eventTitle: String!
ticket: Ticket!
}
type User {
id: ID!
firstName: String!
lastName: String!
age: Int!
username: String!
"""
Shopping cart line items (each entry is one ticket unit). In-memory on the server.
"""
cart: [CartLine!]!
"""Number of tickets in this user's wallet after checkout."""
walletTicketCount: Int!
"""Tickets purchased by this user after a successful `checkout` (in-memory on the server)."""
ticketWallet: [OwnedTicket!]!
"""
Credit card number saved via `saveCreditCard` so the user can skip re-entering it
at checkout. Null if none has been saved. In-memory on the server.
"""
creditCardNumber: String
}
"""
A ticket in the user wallet after checkout: identity, price, and a scannable
EAN-13–style `barcode`. Does not include catalog `quantityAvailable`.
"""
type OwnedTicket {
id: ID!
label: String!
priceCents: Int!
currency: String!
"""13-digit numeric string (EAN-13 with valid check digit)."""
barcode: String!
}
type CartLine {
ticketId: ID!
eventId: ID!
eventTitle: String!
ticketLabel: String!
priceCents: Int!
currency: String!
}
type Cart {
lines: [CartLine!]!
}
type LoginPayload {
accessToken: String
error: Error
}
type LogoutPayload {
ok: Boolean!
error: Error
}
type AuthenticatedUserPayload {
user: User
error: Error
}
type AddToCartPayload {
error: Error
"""Current cart for the user after a successful add; `error` is set on failure."""
cart: Cart
}
type CheckoutPayload {
error: Error
"""Tickets moved into the user wallet after a successful payment; `error` is set on failure."""
purchasedTickets: [OwnedTicket!]
}
type SaveCreditCardPayload {
error: Error
"""The signed-in user after the card was saved; `error` is set on failure."""
user: User
}
"""Human-readable error text for a failed operation. Always null when the call succeeds."""
type Error {
text: String!
}
type Mutation {
"""
Log in with username and password. On success, use `accessToken` on protected mutations; the token is held in memory until logout.
"""
login(username: String!, password: String!): LoginPayload!
"""
End the session for this `accessToken` (removes it from server memory). Requires a valid `accessToken`.
"""
logout(accessToken: String!): LogoutPayload!
"""
Returns the current user for a valid `accessToken`. Includes `ticketWallet`.
"""
authenticatedUser(accessToken: String!): AuthenticatedUserPayload!
"""
Add one unit of a ticket to the signed-in user's cart and decrement in-memory availability for that ticket.
Requires a valid `accessToken`.
"""
addTicketToCart(accessToken: String!, ticketId: ID!): AddToCartPayload!
"""
Pay with a card number, move the current cart into `ticketWallet`, and clear the cart.
The card is validated (length and Luhn) for a believable flow; it is not stored. Requires a valid `accessToken`.
"""
checkout(accessToken: String!, creditCardNumber: String!): CheckoutPayload!
"""
Save a credit card number on the signed-in user so they can skip re-entering it at
checkout. The card is validated (length and Luhn) and stored in memory. Subsequent
reads of `User.creditCardNumber` will return this value. Requires a valid `accessToken`.
"""
saveCreditCard(accessToken: String!, creditCardNumber: String!): SaveCreditCardPayload!
}