-
-
Notifications
You must be signed in to change notification settings - Fork 822
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the merging logic of incremental results to the utils package (#…
…5396) * Move the merging logic of incremental results to the utils package * chore(dependencies): updated changesets for modified dependencies * More * Simplify GraphQL WS excutor --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
f1ca215
commit bb8f169
Showing
12 changed files
with
83 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@graphql-tools/executor-http': patch | ||
--- | ||
dependencies updates: | ||
- Removed dependency [`dset@^3.1.2` ↗︎](https://www.npmjs.com/package/dset/v/3.1.2) (from `dependencies`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@graphql-tools/utils': patch | ||
--- | ||
dependencies updates: | ||
- Added dependency [`dset@^3.1.2` ↗︎](https://www.npmjs.com/package/dset/v/3.1.2) (to `dependencies`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@graphql-tools/executor-graphql-ws': patch | ||
--- | ||
|
||
Simplify GraphQL WS executor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@graphql-tools/executor-http': patch | ||
'@graphql-tools/utils': patch | ||
--- | ||
|
||
Move the merging logic of incremental results to the utils package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { GraphQLError } from 'graphql'; | ||
import { dset } from 'dset/merge'; | ||
import { ExecutionResult } from './Interfaces.js'; | ||
|
||
export function mergeIncrementalResult({ | ||
incrementalResult, | ||
executionResult, | ||
}: { | ||
incrementalResult: ExecutionResult; | ||
executionResult: ExecutionResult; | ||
}) { | ||
if (incrementalResult.path) { | ||
const path = ['data', ...incrementalResult.path]; | ||
executionResult.data = executionResult.data || {}; | ||
if (incrementalResult.items) { | ||
for (const item of incrementalResult.items) { | ||
dset(executionResult, path, item); | ||
} | ||
} | ||
if (incrementalResult.data) { | ||
dset(executionResult, ['data', ...incrementalResult.path], incrementalResult.data); | ||
} | ||
} else if (incrementalResult.data) { | ||
executionResult.data = executionResult.data || {}; | ||
Object.assign(executionResult.data, incrementalResult.data); | ||
} | ||
if (incrementalResult.errors) { | ||
executionResult.errors = executionResult.errors || []; | ||
(executionResult.errors as GraphQLError[]).push(...executionResult.errors); | ||
} | ||
if (incrementalResult.incremental) { | ||
incrementalResult.incremental.forEach(incrementalSubResult => { | ||
mergeIncrementalResult({ | ||
incrementalResult: incrementalSubResult, | ||
executionResult, | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters