From 3f3fdceb773b4fcfb37e8da9a6bf45bb6447a9d9 Mon Sep 17 00:00:00 2001 From: Julien Richard Date: Fri, 18 Nov 2022 18:30:19 +0100 Subject: [PATCH] [back] Improve session screen by batching user fetching --- .../opencti-graphql/src/generated/graphql.ts | 2 ++ opencti-platform/opencti-graphql/src/resolvers/user.js | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/opencti-platform/opencti-graphql/src/generated/graphql.ts b/opencti-platform/opencti-graphql/src/generated/graphql.ts index 8d8dde29be0f..233b51e53076 100644 --- a/opencti-platform/opencti-graphql/src/generated/graphql.ts +++ b/opencti-platform/opencti-graphql/src/generated/graphql.ts @@ -4836,6 +4836,7 @@ export enum IdentitiesFilter { Name = 'name', Revoked = 'revoked', UpdatedAt = 'updated_at', + XOpenctiAliases = 'x_opencti_aliases', XOpenctiWorkflowId = 'x_opencti_workflow_id' } @@ -6896,6 +6897,7 @@ export enum LocationType { } export enum LocationsFilter { + Aliases = 'aliases', Confidence = 'confidence', Created = 'created', CreatedBy = 'createdBy', diff --git a/opencti-platform/opencti-graphql/src/resolvers/user.js b/opencti-platform/opencti-graphql/src/resolvers/user.js index 23ce9dc935da..0fd43b48c249 100644 --- a/opencti-platform/opencti-graphql/src/resolvers/user.js +++ b/opencti-platform/opencti-graphql/src/resolvers/user.js @@ -3,10 +3,13 @@ import { withFilter } from 'graphql-subscriptions'; import { addBookmark, addUser, + assignOrganizationToUser, authenticateUser, batchGroups, + batchOrganizations, batchRoleCapabilities, batchRoles, + batchUsers, bookmarks, deleteBookmark, findAll, @@ -29,14 +32,12 @@ import { userAddRelation, userCleanContext, userDelete, + userDeleteOrganizationRelation, userEditContext, userEditField, userIdDeleteRelation, userRenewToken, userWithOrigin, - batchOrganizations, - assignOrganizationToUser, - userDeleteOrganizationRelation, } from '../domain/user'; import { BUS_TOPICS, logApp, logAudit } from '../config/conf'; import passport, { PROVIDERS } from '../config/providers'; @@ -55,6 +56,7 @@ const groupsLoader = batchLoader(batchGroups); const organizationsLoader = batchLoader(batchOrganizations); const rolesLoader = batchLoader(batchRoles); const rolesCapabilitiesLoader = batchLoader(batchRoleCapabilities); +const usersLoader = batchLoader(batchUsers); const userResolvers = { Query: { @@ -81,7 +83,7 @@ const userResolvers = { userSubscriptions: (current, _, context) => getUserSubscriptions(context, context.user, current.id), }, UserSession: { - user: (session, _, context) => findById(context, context.user, session.user_id), + user: (session, _, context) => usersLoader.load(session.user_id, context, context.user), }, SessionDetail: { ttl: (session) => fetchSessionTtl(session.id),