Skip to content

Commit 904a22d

Browse files
committed
feat(project): add rate limit settings to project update and type definitions
1 parent 26398b0 commit 904a22d

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

src/resolvers/project.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ module.exports = {
141141
*
142142
* @returns {Project}
143143
*/
144-
async updateProject(_obj, { id, name, description, image }, { user, factories }) {
144+
async updateProject(
145+
_obj,
146+
{ id, name, description, image, rateLimitSettings },
147+
{ user, factories }
148+
) {
145149
if (!Validator.string(name)) {
146150
throw new UserInputError('Invalid name length');
147151
}
@@ -170,6 +174,10 @@ module.exports = {
170174
options.image = image;
171175
}
172176

177+
if (rateLimitSettings) {
178+
options.rateLimitSettings = rateLimitSettings;
179+
}
180+
173181
return project.updateProject(options);
174182
} catch (err) {
175183
throw new ApolloError('Something went wrong');

src/typeDefs/project.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
11
import { gql } from 'apollo-server-express';
22

33
export default gql`
4+
"""
5+
Rate limits configuration input
6+
"""
7+
input RateLimitSettingsInput {
8+
"""
9+
Rate limit threshold (N events)
10+
"""
11+
N: Int!
12+
13+
"""
14+
Rate limit period in seconds (T seconds)
15+
"""
16+
T: Int!
17+
}
18+
19+
"""
20+
Rate limits configuration
21+
"""
22+
type RateLimitSettings {
23+
"""
24+
Rate limit threshold (N events)
25+
"""
26+
N: Int!
27+
28+
"""
29+
Rate limit period in seconds (T seconds)
30+
"""
31+
T: Int!
32+
}
433
534
"""
635
Possible events order
@@ -253,6 +282,11 @@ type Project {
253282
Event grouping patterns
254283
"""
255284
eventGroupingPatterns: [ProjectEventGroupingPattern]
285+
286+
"""
287+
Rate limits configuration
288+
"""
289+
rateLimitSettings: RateLimitSettings
256290
}
257291
258292
extend type Query {
@@ -305,6 +339,11 @@ extend type Mutation {
305339
Project image
306340
"""
307341
image: Upload @uploadImage
342+
343+
"""
344+
Rate limits configuration
345+
"""
346+
rateLimitSettings: RateLimitSettingsInput
308347
): Project! @requireAdmin
309348
310349
"""

0 commit comments

Comments
 (0)