From c31d01b2c2f1d125b27d3a18d7f1302bf25fe341 Mon Sep 17 00:00:00 2001 From: darkskygit Date: Fri, 14 Mar 2025 08:02:11 +0000 Subject: [PATCH] chore(server): merge duplicate queries (#10857) --- .../blocksuite/ai/provider/copilot-client.ts | 4 +- .../copilot-context-list-docs-and-files.gql | 22 --------- ...st.gql => copilot-context-list-object.gql} | 3 +- .../frontend/graphql/src/graphql/index.ts | 34 ++----------- packages/frontend/graphql/src/schema.ts | 49 ++----------------- 5 files changed, 13 insertions(+), 99 deletions(-) delete mode 100644 packages/frontend/graphql/src/graphql/copilot-context-list-docs-and-files.gql rename packages/frontend/graphql/src/graphql/{copilot-context-file-list.gql => copilot-context-list-object.gql} (90%) diff --git a/packages/frontend/core/src/blocksuite/ai/provider/copilot-client.ts b/packages/frontend/core/src/blocksuite/ai/provider/copilot-client.ts index 79c687a180..8268ee5063 100644 --- a/packages/frontend/core/src/blocksuite/ai/provider/copilot-client.ts +++ b/packages/frontend/core/src/blocksuite/ai/provider/copilot-client.ts @@ -17,7 +17,7 @@ import { getCopilotHistoryIdsQuery, getCopilotSessionsQuery, type GraphQLQuery, - listContextDocsAndFilesQuery, + listContextObjectQuery, listContextQuery, matchContextQuery, type QueryOptions, @@ -295,7 +295,7 @@ export class CopilotClient { contextId: string ) { const res = await this.gql({ - query: listContextDocsAndFilesQuery, + query: listContextObjectQuery, variables: { workspaceId, sessionId, diff --git a/packages/frontend/graphql/src/graphql/copilot-context-list-docs-and-files.gql b/packages/frontend/graphql/src/graphql/copilot-context-list-docs-and-files.gql deleted file mode 100644 index 42b775dd05..0000000000 --- a/packages/frontend/graphql/src/graphql/copilot-context-list-docs-and-files.gql +++ /dev/null @@ -1,22 +0,0 @@ -query listContextDocsAndFiles($workspaceId: String!, $sessionId: String!, $contextId: String!) { - currentUser { - copilot(workspaceId: $workspaceId) { - contexts(sessionId: $sessionId, contextId: $contextId) { - docs { - id - status - createdAt - } - files { - id - name - blobId - chunkSize - error - status - createdAt - } - } - } - } -} \ No newline at end of file diff --git a/packages/frontend/graphql/src/graphql/copilot-context-file-list.gql b/packages/frontend/graphql/src/graphql/copilot-context-list-object.gql similarity index 90% rename from packages/frontend/graphql/src/graphql/copilot-context-file-list.gql rename to packages/frontend/graphql/src/graphql/copilot-context-list-object.gql index 7808e4c07f..72e054abed 100644 --- a/packages/frontend/graphql/src/graphql/copilot-context-file-list.gql +++ b/packages/frontend/graphql/src/graphql/copilot-context-list-object.gql @@ -1,4 +1,4 @@ -query listContextFiles( +query listContextObject( $workspaceId: String! $sessionId: String! $contextId: String! @@ -8,6 +8,7 @@ query listContextFiles( contexts(sessionId: $sessionId, contextId: $contextId) { docs { id + status createdAt } files { diff --git a/packages/frontend/graphql/src/graphql/index.ts b/packages/frontend/graphql/src/graphql/index.ts index 66b9a6c11c..5878d8abc4 100644 --- a/packages/frontend/graphql/src/graphql/index.ts +++ b/packages/frontend/graphql/src/graphql/index.ts @@ -179,32 +179,6 @@ export const addContextFileMutation = { file: true, }; -export const listContextFilesQuery = { - id: 'listContextFilesQuery' as const, - op: 'listContextFiles', - query: `query listContextFiles($workspaceId: String!, $sessionId: String!, $contextId: String!) { - currentUser { - copilot(workspaceId: $workspaceId) { - contexts(sessionId: $sessionId, contextId: $contextId) { - docs { - id - createdAt - } - files { - id - name - blobId - chunkSize - error - status - createdAt - } - } - } - } -}`, -}; - export const matchContextQuery = { id: 'matchContextQuery' as const, op: 'matchContext', @@ -232,10 +206,10 @@ export const removeContextFileMutation = { }`, }; -export const listContextDocsAndFilesQuery = { - id: 'listContextDocsAndFilesQuery' as const, - op: 'listContextDocsAndFiles', - query: `query listContextDocsAndFiles($workspaceId: String!, $sessionId: String!, $contextId: String!) { +export const listContextObjectQuery = { + id: 'listContextObjectQuery' as const, + op: 'listContextObject', + query: `query listContextObject($workspaceId: String!, $sessionId: String!, $contextId: String!) { currentUser { copilot(workspaceId: $workspaceId) { contexts(sessionId: $sessionId, contextId: $contextId) { diff --git a/packages/frontend/graphql/src/schema.ts b/packages/frontend/graphql/src/schema.ts index 27f5a5021c..d172209260 100644 --- a/packages/frontend/graphql/src/schema.ts +++ b/packages/frontend/graphql/src/schema.ts @@ -2363,40 +2363,6 @@ export type AddContextFileMutation = { }; }; -export type ListContextFilesQueryVariables = Exact<{ - workspaceId: Scalars['String']['input']; - sessionId: Scalars['String']['input']; - contextId: Scalars['String']['input']; -}>; - -export type ListContextFilesQuery = { - __typename?: 'Query'; - currentUser: { - __typename?: 'UserType'; - copilot: { - __typename?: 'Copilot'; - contexts: Array<{ - __typename?: 'CopilotContext'; - docs: Array<{ - __typename?: 'CopilotContextDoc'; - id: string; - createdAt: number; - }>; - files: Array<{ - __typename?: 'CopilotContextFile'; - id: string; - name: string; - blobId: string; - chunkSize: number; - error: string | null; - status: ContextEmbedStatus; - createdAt: number; - }>; - }>; - }; - } | null; -}; - export type MatchContextQueryVariables = Exact<{ contextId: Scalars['String']['input']; content: Scalars['String']['input']; @@ -2432,13 +2398,13 @@ export type RemoveContextFileMutation = { removeContextFile: boolean; }; -export type ListContextDocsAndFilesQueryVariables = Exact<{ +export type ListContextObjectQueryVariables = Exact<{ workspaceId: Scalars['String']['input']; sessionId: Scalars['String']['input']; contextId: Scalars['String']['input']; }>; -export type ListContextDocsAndFilesQuery = { +export type ListContextObjectQuery = { __typename?: 'Query'; currentUser: { __typename?: 'UserType'; @@ -4028,20 +3994,15 @@ export type Queries = variables: ListBlobsQueryVariables; response: ListBlobsQuery; } - | { - name: 'listContextFilesQuery'; - variables: ListContextFilesQueryVariables; - response: ListContextFilesQuery; - } | { name: 'matchContextQuery'; variables: MatchContextQueryVariables; response: MatchContextQuery; } | { - name: 'listContextDocsAndFilesQuery'; - variables: ListContextDocsAndFilesQueryVariables; - response: ListContextDocsAndFilesQuery; + name: 'listContextObjectQuery'; + variables: ListContextObjectQueryVariables; + response: ListContextObjectQuery; } | { name: 'listContextQuery';