From 1f9ae86abe4ac088c470cf0d976e1de93e36067f Mon Sep 17 00:00:00 2001 From: Alejandro Estrada Date: Mon, 30 Jan 2023 12:51:32 -0500 Subject: [PATCH] chore: update name for graphql batch operations (#25610) * feat: update name for graphql batch operations * Validate selection kind * Update packages/data-context/src/sources/CloudDataSource.ts Co-authored-by: Tim Griesser --------- Co-authored-by: Tim Griesser --- .../data-context/src/sources/CloudDataSource.ts | 17 ++++++++++++++++- .../cypress/e2e/e2ePluginSetup.ts | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/data-context/src/sources/CloudDataSource.ts b/packages/data-context/src/sources/CloudDataSource.ts index d8948a91aa86..d43bcbab9a3d 100644 --- a/packages/data-context/src/sources/CloudDataSource.ts +++ b/packages/data-context/src/sources/CloudDataSource.ts @@ -402,11 +402,26 @@ function namedExecutionDocument (document: DocumentNode) { } hasReplaced = true + + const selectionSet = new Set() + + op.selectionSet.selections.forEach((s) => { + if (s.kind === 'Field') { + selectionSet.add(s.name.value) + } + }) + + let operationName = 'batchTestRunnerExecutionQuery' + + if (selectionSet.size > 0) { + operationName = `${operationName}_${Array.from(selectionSet).sort().join('_')}` + } + const namedOperationNode: OperationDefinitionNode = { ...op, name: { kind: 'Name', - value: 'batchTestRunnerExecutionQuery', + value: operationName, }, } diff --git a/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts b/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts index 79bd2b333768..87895f4fd502 100644 --- a/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts +++ b/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts @@ -239,7 +239,7 @@ async function makeE2ETasks () { operationCount[operationName ?? 'unknown']++ - if (operationName === 'batchTestRunnerExecutionQuery' && remoteGraphQLInterceptBatched) { + if (operationName?.startsWith('batchTestRunnerExecutionQuery') && remoteGraphQLInterceptBatched) { const fn = remoteGraphQLInterceptBatched const keys: string[] = [] const values: Promise[] = []