Skip to content

Commit 80f54fc

Browse files
committed
feat(project): implement updateProjectRateLimits mutation for modifying project rate limit settings
1 parent 56dcbe9 commit 80f54fc

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

src/resolvers/project.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,37 @@ module.exports = {
184184
}
185185
},
186186

187+
/**
188+
* Update project rate limits settings
189+
*
190+
* @param {ResolverObj} _obj
191+
* @param {string} id - project id
192+
* @param {Object} rateLimitSettings - rate limit settings
193+
* @param {UserInContext} user - current authorized user {@see ../index.js}
194+
* @param {ContextFactories} factories - factories for working with models
195+
*
196+
* @returns {Project}
197+
*/
198+
async updateProjectRateLimits(_obj, { id, rateLimitSettings }, { user, factories }) {
199+
const project = await factories.projectsFactory.findById(id);
200+
201+
if (!project) {
202+
throw new ApolloError('There is no project with that id');
203+
}
204+
205+
if (project.workspaceId.toString() === '6213b6a01e6281087467cc7a') {
206+
throw new ApolloError('Unable to update demo project');
207+
}
208+
209+
try {
210+
return project.updateProject({
211+
rateLimitSettings,
212+
});
213+
} catch (err) {
214+
throw new ApolloError('Something went wrong');
215+
}
216+
},
217+
187218
/**
188219
* Generates new project integration token by id
189220
*

src/typeDefs/project.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,21 @@ extend type Mutation {
346346
rateLimitSettings: RateLimitSettingsInput
347347
): Project! @requireAdmin
348348
349+
"""
350+
Update project rate limits settings
351+
"""
352+
updateProjectRateLimits(
353+
"""
354+
What project to update
355+
"""
356+
id: ID!
357+
358+
"""
359+
Rate limits configuration
360+
"""
361+
rateLimitSettings: RateLimitSettingsInput!
362+
): Project! @requireAdmin
363+
349364
"""
350365
Generates new project integration token by id
351366
"""

0 commit comments

Comments
 (0)