Skip to content

Commit 6be9831

Browse files
committed
feat(project): add removeProjectRateLimits mutation to clear project rate limit settings
1 parent 80f54fc commit 6be9831

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

src/resolvers/project.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,34 @@ module.exports = {
215215
}
216216
},
217217

218+
/**
219+
* Remove project rate limits settings
220+
*
221+
* @param {ResolverObj} _obj
222+
* @param {string} id - project id
223+
* @param {UserInContext} user - current authorized user {@see ../index.js}
224+
* @param {ContextFactories} factories - factories for working with models
225+
*
226+
* @returns {Project}
227+
*/
228+
async removeProjectRateLimits(_obj, { id }, { user, factories }) {
229+
const project = await factories.projectsFactory.findById(id);
230+
231+
if (!project) {
232+
throw new ApolloError('There is no project with that id');
233+
}
234+
235+
if (project.workspaceId.toString() === '6213b6a01e6281087467cc7a') {
236+
throw new ApolloError('Unable to update demo project');
237+
}
238+
239+
try {
240+
return project.updateProject(null, { rateLimitSettings: '' });
241+
} catch (err) {
242+
throw new ApolloError('Something went wrong');
243+
}
244+
},
245+
218246
/**
219247
* Generates new project integration token by id
220248
*

src/typeDefs/project.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,16 @@ extend type Mutation {
361361
rateLimitSettings: RateLimitSettingsInput!
362362
): Project! @requireAdmin
363363
364+
"""
365+
Remove project rate limits settings
366+
"""
367+
removeProjectRateLimits(
368+
"""
369+
What project to update
370+
"""
371+
id: ID!
372+
): Project! @requireAdmin
373+
364374
"""
365375
Generates new project integration token by id
366376
"""

0 commit comments

Comments
 (0)