Browse Source

Maintenance: Desktop view - Add possibility to skip batching per query.

Dominik Klein 1 month ago
parent
commit
7c1489eea5

+ 1 - 1
app/frontend/apps/desktop/AppDesktop.vue

@@ -72,8 +72,8 @@ watch(
   (newValue, oldValue) => {
     if (!newValue || oldValue) return
 
-    useTicketOverviewsStore()
     useUserCurrentTaskbarTabsStore()
+    useTicketOverviewsStore()
     initializeDefaultObjectAttributes()
   },
   { immediate: true },

+ 10 - 1
app/frontend/apps/desktop/entities/ticket/stores/ticketOverviews.ts

@@ -74,7 +74,16 @@ export const useTicketOverviewsStore = defineStore('ticketOverviews', () => {
   )
 
   const ticketOverviewTicketCountHandler = new QueryHandler(
-    useTicketOverviewTicketCountQuery({ ignoreUserConditions: false }),
+    useTicketOverviewTicketCountQuery(
+      { ignoreUserConditions: false },
+      {
+        context: {
+          batch: {
+            active: false,
+          },
+        },
+      },
+    ),
   )
 
   const overviewsTicketCount = ticketOverviewTicketCountHandler.result()

+ 10 - 1
app/frontend/apps/desktop/entities/user/current/stores/taskbarTabs.ts

@@ -60,7 +60,16 @@ export const useUserCurrentTaskbarTabsStore = defineStore(
       userTaskbarTabPluginByType[tabEntityType]
 
     const taskbarTabsQuery = new QueryHandler(
-      useUserCurrentTaskbarItemListQuery({ app: EnumTaskbarApp.Desktop }),
+      useUserCurrentTaskbarItemListQuery(
+        { app: EnumTaskbarApp.Desktop },
+        {
+          context: {
+            batch: {
+              active: false,
+            },
+          },
+        },
+      ),
     )
 
     const taskbarTabsRaw = taskbarTabsQuery.result()

+ 5 - 0
app/frontend/shared/components/Form/Form.vue

@@ -1333,6 +1333,11 @@ const initializeFormSchema = () => {
         useFormUpdaterQuery(
           formUpdaterVariables as Ref<FormUpdaterQueryVariables>,
           {
+            context: {
+              batch: {
+                active: false,
+              },
+            },
             fetchPolicy: 'no-cache',
           },
         ),

+ 14 - 5
app/frontend/shared/entities/ticket-article/composables/useArticleDataHandler.ts

@@ -39,11 +39,20 @@ export const useArticleDataHandler = (
   )
 
   const articlesQuery = new QueryHandler(
-    useTicketArticlesQuery(() => ({
-      ticketId: ticketId.value,
-      pageSize: options.pageSize || 20,
-      firstArticlesCount: firstArticlesCount.value,
-    })),
+    useTicketArticlesQuery(
+      () => ({
+        ticketId: ticketId.value,
+        pageSize: options.pageSize || 20,
+        firstArticlesCount: firstArticlesCount.value,
+      }),
+      {
+        context: {
+          batch: {
+            active: false,
+          },
+        },
+      },
+    ),
   )
 
   const articleResult = articlesQuery.result()

+ 5 - 4
app/frontend/shared/server/apollo/link.ts

@@ -14,6 +14,7 @@ import debugLink from './link/debug.ts'
 import errorLink from './link/error.ts'
 import setAuthorizationLink from './link/setAuthorization.ts'
 import testFlagsLink from './link/testFlags.ts'
+import getBatchContext from './utils/getBatchContext.ts'
 
 import type { Operation } from '@apollo/client/core'
 import type { FragmentDefinitionNode, OperationDefinitionNode } from 'graphql'
@@ -63,10 +64,10 @@ const operationIsFormUpdater = (
 
 const requiresBatchLink = (op: Operation) => {
   if (!enableBatchLink) return false
-  const definition = getMainDefinition(op.query)
-  return (
-    !operationIsLoginLogout(definition) && !operationIsFormUpdater(definition)
-  )
+
+  const batchContext = getBatchContext(op)
+
+  return batchContext.active
 }
 
 const httpLink = ApolloLink.split(requiresBatchLink, batchLink, noBatchLink)

+ 17 - 0
app/frontend/shared/server/apollo/utils/getBatchContext.ts

@@ -0,0 +1,17 @@
+// Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
+
+import type { ClientBatchContext } from '#shared/types/server/apollo/client.ts'
+
+import type { Operation } from '@apollo/client/core'
+
+export default function getBatchContext(
+  operation: Operation,
+): ClientBatchContext {
+  const defaultBatchContext: ClientBatchContext = {
+    active: true,
+  }
+  const context = operation.getContext()
+  const batch: Partial<ClientBatchContext> = context.batch || {}
+
+  return Object.assign(defaultBatchContext, batch)
+}

+ 12 - 1
app/frontend/shared/stores/authentication.ts

@@ -59,7 +59,15 @@ export const useAuthenticationStore = defineStore(
     }
 
     const logout = async (): Promise<void> => {
-      const logoutMutation = new MutationHandler(useLogoutMutation())
+      const logoutMutation = new MutationHandler(
+        useLogoutMutation({
+          context: {
+            batch: {
+              active: false,
+            },
+          },
+        }),
+      )
 
       const result = await logoutMutation.send()
       if (result?.logout?.success) {
@@ -123,6 +131,9 @@ export const useAuthenticationStore = defineStore(
             headers: {
               'X-Browser-Fingerprint': fingerprint.value,
             },
+            batch: {
+              active: false,
+            },
           },
         }),
       )

+ 4 - 0
app/frontend/shared/types/server/apollo/client.ts

@@ -16,6 +16,10 @@ export interface ClientErrorContext {
   logLevel: LogLevel
 }
 
+export interface ClientBatchContext {
+  active: boolean
+}
+
 export interface DebugLinkRequestOutput {
   requestHeaders?: Record<string, string>
   printedDocument: string