-
-
Notifications
You must be signed in to change notification settings - Fork 818
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove info from ExecutionParams and add operationType (#3166)
* Remove info from ExecutionParams and add operationType * Fix tests * Allow getBatchingExecutor to cache executor by memoizing default executor * Memoize for a single so allow to memoize correctly. * Rename Request to ExecutionRequest * Remove unnecessary diff * Remove unnecessary operationName from DelegationContext * Add `context` in `createRequest` and `createRequestInfo` instead of `delegateToSchema` * Get context from request * Do not export extra types from delegate * Add info back * Fix typings
- Loading branch information
Showing
51 changed files
with
266 additions
and
219 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,25 @@ | ||
--- | ||
'@graphql-tools/batch-execute': major | ||
'@graphql-tools/delegate': major | ||
'@graphql-tools/links': major | ||
'@graphql-tools/utils': major | ||
'@graphql-tools/wrap': major | ||
--- | ||
|
||
BREAKING CHANGES; | ||
|
||
- Rename `Request` to `ExecutionRequest` | ||
- Drop unnecessary `GraphQLResolveInfo` in `ExecutionRequest` | ||
- Add required `operationType: OperationTypeNode` field in `ExecutionRequest` | ||
- Add `context` in `createRequest` and `createRequestInfo` instead of `delegateToSchema` | ||
|
||
> It doesn't rely on info.operation.operationType to allow the user to call an operation from different root type. | ||
And it doesn't call getOperationAST again and again to get operation type from the document/operation because we have it in Request and ExecutionParams | ||
https://github.com/ardatan/graphql-tools/pull/3166/files#diff-d4824895ea613dcc1f710c3ac82e952fe0ca12391b671f70d9f2d90d5656fdceR38 | ||
|
||
Improvements; | ||
- Memoize `defaultExecutor` for a single `GraphQLSchema` so allow `getBatchingExecutor` to memoize `batchingExecutor` correctly. | ||
- And there is no different `defaultExecutor` is created for `subscription` and other operation types. Only one executor is used. | ||
|
||
> Batch executor is memoized by `executor` reference but `createDefaultExecutor` didn't memoize the default executor so this memoization wasn't working correctly on `batch-execute` side. | ||
https://github.com/ardatan/graphql-tools/blob/remove-info-executor/packages/batch-execute/src/getBatchingExecutor.ts#L9 |
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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import DataLoader from 'dataloader'; | ||
|
||
import { Request, Executor } from '@graphql-tools/utils'; | ||
import { ExecutionRequest, Executor } from '@graphql-tools/utils'; | ||
import { createBatchingExecutor } from './createBatchingExecutor'; | ||
import { memoize2of4 } from './memoize'; | ||
|
||
export const getBatchingExecutor = memoize2of4(function ( | ||
export const getBatchingExecutor = memoize2of4(function getBatchingExecutor( | ||
_context: Record<string, any>, | ||
executor: Executor, | ||
dataLoaderOptions?: DataLoader.Options<any, any, any> | undefined, | ||
extensionsReducer?: undefined | ((mergedExtensions: Record<string, any>, request: Request) => Record<string, any>) | ||
extensionsReducer?: | ||
| undefined | ||
| ((mergedExtensions: Record<string, any>, request: ExecutionRequest) => Record<string, any>) | ||
): Executor { | ||
return createBatchingExecutor(executor, dataLoaderOptions, extensionsReducer); | ||
}); |
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
Oops, something went wrong.