chore(multiregion): small fixes to resolvers

This commit is contained in:
Alessandro Magionami
2024-11-21 12:20:03 +01:00
parent 2a7c51f3df
commit 7cb51dc0e4
4 changed files with 14 additions and 14 deletions
@@ -190,9 +190,9 @@ export = {
// If limit=0, short-cut full execution and use data loader
if (args.limit === 0) {
return {
totalCount: await ctx.loaders.streams.getCommitCountWithoutGlobals.load(
parent.id
),
totalCount: await ctx.loaders
.forRegion({ db: projectDB })
.streams.getCommitCountWithoutGlobals.load(parent.id),
items: [],
cursor: null
}
@@ -8,7 +8,6 @@ import {
storeClosuresIfNotFoundFactory,
storeObjectsIfNotFoundFactory
} from '@/modules/core/repositories/objects'
import { db } from '@/db/knex'
import { createObjectsFactory } from '@/modules/core/services/objects/management'
import { getProjectDbClient } from '@/modules/multiregion/dbSelector'
@@ -37,7 +36,7 @@ export = {
const projectDB = await getProjectDbClient({ projectId: parent.streamId })
// The simple query branch
if (!args.query && !args.orderBy) {
const getObjectChildren = getObjectChildrenFactory({ db })
const getObjectChildren = getObjectChildrenFactory({ db: projectDB })
const result = await getObjectChildren({
streamId: parent.streamId,
objectId: parent.id,
@@ -271,6 +271,7 @@ export = {
})
return await updateStreamAndNotify(update, userId!, resourceAccessRules)
},
// This one is only used outside of a workspace, so the project is always created in the main db
async create(_parent, args, context) {
const rateLimitResult = await getRateLimitResult('STREAM_CREATE', context.userId!)
if (isRateLimitBreached(rateLimitResult)) {
@@ -231,7 +231,7 @@ export = {
return stream
},
async streams(parent, args, context) {
async streams(_, args, context) {
const totalCount = await getUserStreamsCount({
userId: context.userId!,
searchQuery: args.query || undefined,
@@ -248,14 +248,14 @@ export = {
return { totalCount, cursor, items: streams }
},
async discoverableStreams(parent, args, ctx) {
async discoverableStreams(_, args, ctx) {
return await getDiscoverableStreams(
args,
toProjectIdWhitelist(ctx.resourceAccessRules)
)
},
async adminStreams(parent, args, ctx) {
async adminStreams(_, args, ctx) {
if (args.limit && args.limit > 50)
throw new BadRequestError('Cannot return more than 50 items at a time.')
@@ -389,7 +389,7 @@ export = {
}
},
Mutation: {
async streamCreate(parent, args, context) {
async streamCreate(_, args, context) {
const rateLimitResult = await getRateLimitResult('STREAM_CREATE', context.userId!)
if (isRateLimitBreached(rateLimitResult)) {
throw new RateLimitError(rateLimitResult)
@@ -404,7 +404,7 @@ export = {
return id
},
async streamUpdate(parent, args, context) {
async streamUpdate(_, args, context) {
await updateStreamAndNotify(
args.stream,
context.userId!,
@@ -413,7 +413,7 @@ export = {
return true
},
async streamDelete(parent, args, context) {
async streamDelete(_, args, context) {
return await deleteStreamAndNotify(
args.id,
context.userId!,
@@ -422,7 +422,7 @@ export = {
)
},
async streamsDelete(parent, args, context) {
async streamsDelete(_, args, context) {
const results = await Promise.all(
(args.ids || []).map(async (id) => {
return await deleteStreamAndNotify(
@@ -436,7 +436,7 @@ export = {
return results.every((res) => res === true)
},
async streamUpdatePermission(parent, args, context) {
async streamUpdatePermission(_, args, context) {
const result = await updateStreamRoleAndNotify(
args.permissionParams,
context.userId!,
@@ -445,7 +445,7 @@ export = {
return !!result
},
async streamRevokePermission(parent, args, context) {
async streamRevokePermission(_, args, context) {
const result = await updateStreamRoleAndNotify(
args.permissionParams,
context.userId!,