Skip to content

Commit

Permalink
Remove graphql-executor to have smaller bundle size (#4533)
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Jun 23, 2022
1 parent a84952f commit 6df204d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-countries-boil.md
@@ -0,0 +1,5 @@
---
'@graphql-tools/delegate': patch
---

Remove graphql-executor to have smaller bundle size
3 changes: 1 addition & 2 deletions benchmark/federation/index.js
Expand Up @@ -2,8 +2,7 @@ const express = require('express');
const runStitchingGateway = require('./stitching');
const runApolloGateway = require('./federation');
const makeMonolithSchema = require('./monolith');
const { parse } = require('graphql');
const { execute } = require('graphql-executor');
const { parse, execute } = require('graphql');

function memoize1(fn) {
const memoize1cache = new Map();
Expand Down
1 change: 0 additions & 1 deletion benchmark/federation/package.json
Expand Up @@ -15,7 +15,6 @@
"@graphql-tools/stitching-directives": "2.2.18",
"express": "4.18.1",
"graphql": "16.5.0",
"graphql-executor": "0.0.23",
"graphql-tag": "2.12.6",
"wait-on": "6.0.1",
"cross-env": "7.0.3"
Expand Down
3 changes: 1 addition & 2 deletions packages/delegate/package.json
Expand Up @@ -36,8 +36,7 @@
"@graphql-tools/schema": "8.3.14",
"@graphql-tools/utils": "8.6.13",
"dataloader": "2.1.0",
"graphql-executor": "0.0.23",
"tslib": "^2.4.0",
"tslib": "~2.4.0",
"value-or-promise": "1.0.11"
},
"publishConfig": {
Expand Down
15 changes: 10 additions & 5 deletions packages/delegate/src/delegateToSchema.ts
Expand Up @@ -5,10 +5,11 @@ import {
OperationTypeNode,
DocumentNode,
GraphQLOutputType,
ExecutionArgs,
subscribe,
execute,
} from 'graphql';

import { Executor as GraphQLExecutor, ExecutorExecutionArgs } from 'graphql-executor';

import { ValueOrPromise } from 'value-or-promise';

import { getBatchingExecutor } from '@graphql-tools/batch-execute';
Expand Down Expand Up @@ -216,15 +217,19 @@ function getExecutor<TContext extends Record<string, any>>(
}

export const createDefaultExecutor = memoize1(function createDefaultExecutor(schema: GraphQLSchema): Executor {
const executorInstance = new GraphQLExecutor({ schema });
return function defaultExecutor(request: ExecutionRequest) {
const executionArgs: ExecutorExecutionArgs = {
const executionArgs: ExecutionArgs = {
schema,
document: request.document,
rootValue: request.rootValue,
contextValue: request.context,
variableValues: request.variables,
operationName: request.operationName,
};
return executorInstance.execute(executionArgs);
const operationType = request.operationType || getOperationASTFromRequest(request).operation;
if (operationType === 'subscription') {
return subscribe(executionArgs);
}
return execute(executionArgs);
} as Executor;
});
7 changes: 1 addition & 6 deletions yarn.lock
Expand Up @@ -7559,11 +7559,6 @@ graphlib@^2.1.8:
dependencies:
lodash "^4.17.15"

graphql-executor@0.0.23:
version "0.0.23"
resolved "https://registry.yarnpkg.com/graphql-executor/-/graphql-executor-0.0.23.tgz#205c1764b39ee0fcf611553865770f37b45851a2"
integrity sha512-3Ivlyfjaw3BWmGtUSnMpP/a4dcXCp0mJtj0PiPG14OKUizaMKlSEX+LX2Qed0LrxwniIwvU6B4w/koVjEPyWJg==

graphql-request@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/graphql-request/-/graphql-request-4.0.0.tgz#5e4361d33df1a95ccd7ad23a8ebb6bbca9d5622f"
Expand Down Expand Up @@ -13219,7 +13214,7 @@ tslib@1.11.1, tslib@^1.0.0, tslib@^1.11.1, tslib@^1.8.1, tslib@^1.9.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35"
integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==

tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0:
tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0, tslib@~2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"
integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==
Expand Down

0 comments on commit 6df204d

Please sign in to comment.