Skip to content

Commit 4ba798d

Browse files
committed
refactor(project): update rateLimitSettings handling to allow null for removal and clean up type definitions
1 parent 6be9831 commit 4ba798d

File tree

2 files changed

+4
-42
lines changed

2 files changed

+4
-42
lines changed

src/resolvers/project.js

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ module.exports = {
189189
*
190190
* @param {ResolverObj} _obj
191191
* @param {string} id - project id
192-
* @param {Object} rateLimitSettings - rate limit settings
192+
* @param {Object | null} rateLimitSettings - rate limit settings (null to remove)
193193
* @param {UserInContext} user - current authorized user {@see ../index.js}
194194
* @param {ContextFactories} factories - factories for working with models
195195
*
@@ -208,41 +208,13 @@ module.exports = {
208208

209209
try {
210210
return project.updateProject({
211-
rateLimitSettings,
211+
rateLimitSettings: rateLimitSettings || null,
212212
});
213213
} catch (err) {
214214
throw new ApolloError('Something went wrong');
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-
246218
/**
247219
* Generates new project integration token by id
248220
*

src/typeDefs/project.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -356,19 +356,9 @@ extend type Mutation {
356356
id: ID!
357357
358358
"""
359-
Rate limits configuration
360-
"""
361-
rateLimitSettings: RateLimitSettingsInput!
362-
): Project! @requireAdmin
363-
364-
"""
365-
Remove project rate limits settings
366-
"""
367-
removeProjectRateLimits(
368-
"""
369-
What project to update
359+
Rate limits configuration. Pass null to remove rate limits.
370360
"""
371-
id: ID!
361+
rateLimitSettings: RateLimitSettingsInput
372362
): Project! @requireAdmin
373363
374364
"""

0 commit comments

Comments
 (0)