-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.gql
209 lines (174 loc) · 4.82 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
# ------------------------------------------------------
# THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)
# ------------------------------------------------------
schema {
query: Query
mutation: Mutation
subscription: Subscription
}
"""
requires authorization
allowed forms:
- http headers
- Authorization: Bearer <token>
"""
directive @auth(
"""if resource is not owned by current user field id nulled"""
onlyOwn: Boolean = false
optional: Boolean = false
) on FIELD_DEFINITION
"""
requires balance to be high enough
if it's too low returns BalanceTooLowError
"""
directive @balance on FIELD_DEFINITION
directive @constraint(contains: String, endsWith: String, exclusiveMax: Float, exclusiveMin: Float, format: String, max: Float, maxLength: Int, min: Float, minLength: Int, multipleOf: Float, notContains: String, pattern: String, startsWith: String, uniqueTypeName: String) on ARGUMENT_DEFINITION | FIELD_DEFINITION | INPUT_FIELD_DEFINITION
directive @maybeInProgress on FIELD_DEFINITION
type AuthPayload {
token: AuthTokenEntity!
user: UserEntity!
}
type AuthTokenEntity {
createdAt: DateTime!
expiresAt: DateTime!
isExpired: Boolean!
name: String!
token: String!
}
type BalanceEntity {
balance: Int!
}
union BalanceEntityOrBalanceTooLowError = BalanceEntity | BalanceTooLowError
type BalanceTooLowError {
chargeAmount: Int!
currentBalance: Int!
}
"""
A date-time string at UTC, such as 2019-12-03T09:54:33Z, compliant with the date-time format.
"""
scalar DateTime
type DiceRollEntity {
amount: Int!
chances: Int!
createdAt: DateTime!
nonce: Int!
side: DiceRollSide!
user: UserEntity!
winning: Int!
won: Boolean!
}
union DiceRollEntityOrBalanceTooLowError = BalanceTooLowError | DiceRollEntity
input DiceRollInput {
amount: Int! @constraint(min: 1)
chances: Int! @constraint(min: 1, exclusiveMax: 100000)
side: DiceRollSide = LOWER
}
enum DiceRollSide {
LOWER
UPPER
}
type DiceSeedEntity {
clientSeed: String!
hashedNextServerSeed: String!
hashedServerSeed: String!
previousServerSeed: String
}
type InProgressError {
closedAt: DateTime!
nextOpenAt: DateTime
}
input LoginInput {
email: String! @constraint(format: "email")
password: String!
tokenName: String!
}
type Mutation {
deposit(amount: Int!): BalanceEntity! @auth
login(login: LoginInput!): AuthPayload!
logout(register: String!): UserToken! @auth
placeRouletteBet(bet: PlaceRouletteBetInput!): RouletteBetEntityOrBalanceTooLowErrorOrInProgressError @balance @maybeInProgress @auth
register(register: RegisterInput!): AuthPayload!
rollDice(createDiceInput: DiceRollInput!): DiceRollEntityOrBalanceTooLowError @balance @auth
updateDiceSeed(newSeed: String!): DiceSeedEntity! @auth
updateUser(updateUser: UpdateUserInput!): UserEntity! @auth
withdraw(amount: Int!): BalanceEntityOrBalanceTooLowError @balance @auth
}
input PageInput {
skip: Int = 0 @constraint(min: 0)
take: Int = 10 @constraint(exclusiveMin: 0, max: 20)
}
input PlaceRouletteBetInput {
amount: Int! @constraint(exclusiveMin: 0)
color: RouletteBetColor!
}
type Query {
diceRollHistory(page: PageInput!): [DiceRollEntity!]!
"""either there must be specified id or you must be authenticated"""
findUser(id: ID): UserEntity! @auth(optional: true)
rouletteRollHistory(page: PageInput!): [RouletteRollEntity!]!
rouletteSeedsHistory(page: PageInput!): [RouletteSeedEntity!]!
rouletteStats: RouletteStatsEntity!
}
input RegisterInput {
email: String! @constraint(format: "email")
name: String!
password: String!
tokenName: String!
}
enum RouletteBetColor {
BLACK
GREEN
RED
}
type RouletteBetEntity {
amount: Int!
color: RouletteBetColor!
id: ID!
roll: RouletteRollEntity
}
union RouletteBetEntityOrBalanceTooLowError = BalanceTooLowError | RouletteBetEntity
union RouletteBetEntityOrBalanceTooLowErrorOrInProgressError = BalanceTooLowError | InProgressError | RouletteBetEntity
type RouletteRollEntity {
color: RouletteBetColor!
createdAt: DateTime!
nonce: Int!
seed: RouletteSeedEntity!
winning: Int!
}
type RouletteSeedEntity {
day: DateTime!
id: ID!
isHashed: Boolean!
privateKey: String!
publicKey: String!
}
type RouletteStatsEntity {
blackCount: Int!
greenCount: Int!
redCount: Int!
}
type Subscription {
onRouletteResults: RouletteRollEntity!
onRouletteRoll: ID!
}
input UpdateUserInput {
email: String @constraint(format: "email")
name: String
password: String
}
type UserEntity {
balance: Int @auth(onlyOwn: true)
diceRolls(page: PageInput!): [DiceRollEntity!]!
diceSeed: DiceSeedEntity @auth(onlyOwn: true)
email: String @auth(onlyOwn: true)
id: ID!
name: String!
rouletteBets(page: PageInput!): [RouletteBetEntity!]!
tokens: [UserToken!] @auth(onlyOwn: true)
}
type UserToken {
createdAt: DateTime!
expiresAt: DateTime!
isExpired: Boolean!
name: String!
}