Skip to content

Commit 7d3e300

Browse files
committed
Huge cleanup before major release (breaking) (#3081)
* Breaking cleanup before major release * Fix TS * More chore(deps): update typescript-eslint monorepo to v4.28.0 (#3093) Co-authored-by: Renovate Bot <[email protected]> fix(deps): update babel monorepo to v7.14.7 (#3094) Co-authored-by: Renovate Bot <[email protected]> chore(deps): update jest monorepo to v27.0.5 (#3095) Co-authored-by: Renovate Bot <[email protected]> chore(deps): update dependency @vue/compiler-sfc to v3.1.2 (#3097) Co-authored-by: Renovate Bot <[email protected]> fix(deps): update dependency the-guild-components to v1.4.0 (#3098) Co-authored-by: Renovate Bot <[email protected]> chore(deps): update dependency @types/node to v14.17.4 (#3101) Co-authored-by: Renovate Bot <[email protected]> Some other refactor (#3096) * Fix typing errors in tests * ReplaObject.keys/values and forEach with for..in and for..of loops * Improve Type Checking * Update CI workflow * Fix linting * Fix TS errors for v14 * More * More * Allow incremental builds * Finish * Fix Type Check * Disable sourcemaps * Fix type issues Better changelog Respect and in and more changes chore(CI): Ability to release canaries on demand Make AggregateError spec compliant
1 parent 806faae commit 7d3e300

File tree

232 files changed

+2621
-7870
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+2621
-7870
lines changed

.changeset/blue-phones-kick.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@graphql-tools/delegate': major
3+
---
4+
5+
BREAKING CHANGE
6+
- Remove `rootValue` from subschemaConfig
7+
- - Pass it through `ExecutionParams` or delegation options
8+
- Do not pass `info.rootValue` if `rootValue` is falsy

.changeset/brave-rats-march.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@graphql-tools/wrap': major
3+
---
4+
5+
BREAKING CHANGE
6+
- `makeRemoteExecutableSchema` has been removed.
7+
- - You can use [`wrapSchema`](https://www.graphql-tools.com/docs/remote-schemas#creating-an-executor) instead

.changeset/cuddly-horses-prove.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@graphql-tools/utils': major
3+
---
4+
5+
BREAKING CHANGE
6+
- Remove `fieldToFieldConfig`, `argsToFieldConfigArgument` and `argumentToArgumentConfig`
7+
- - You can use `.toConfig` method instead for each.

.changeset/forty-ducks-drum.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@graphql-tools/schema': major
3+
'@graphql-tools/stitch': major
4+
'@graphql-tools/utils': major
5+
---
6+
7+
BREAKING CHANGE
8+
- Legacy Schema Directives and Directive Resolvers have been removed
9+
- - You can check the new method for both;
10+
- - - https://www.graphql-tools.com/docs/schema-directives

.changeset/heavy-vans-whisper.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@graphql-tools/schema': major
3+
---
4+
5+
BREAKING CHANGE
6+
- Remove `logger` and `addErrorLoggingToSchema`
7+
- - You can implement logging and debugging mechanism outside the resolvers using some kind of plugin system based library like [Envelop](https://www.envelop.dev/docs/core#uselogger)
8+

.changeset/long-rings-happen.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'graphql-tools': major
3+
---
4+
5+
BREAKING CHANGE
6+
- Now it only exports `makeExecutableSchema` from `@graphql-tools/schema`
7+
- Please migrate to scoped packages(`@graphql-tools/*`) because this npm package will no longer get updated

.changeset/mean-news-return.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@graphql-tools/delegate': major
3+
'@graphql-tools/apollo-engine-loader': major
4+
'@graphql-tools/utils': major
5+
'@graphql-tools/wrap': major
6+
---
7+
8+
BREAKING CHANGE
9+
- Now it uses the native [`AggregateError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError) implementation. The major difference is the individual errors are kept under `errors` property instead of the object itself with `Symbol.iterator`.
10+
```js
11+
// From;
12+
for (const error of aggregateError)
13+
// To;
14+
for (const error of aggregateError.errors)
15+
```

.changeset/new-balloons-reply.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@graphql-tools/schema': major
3+
---
4+
5+
BREAKING CHANGE
6+
- Remove schema level resolvers feature and `addSchemaLevelResolver`
7+
- - You can wrap your resolvers by using [Resolvers Composition](https://www.graphql-tools.com/docs/resolvers-composition)
8+

.changeset/ninety-shirts-crash.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@graphql-tools/utils': major
3+
---
4+
5+
BREAKING CHANGE
6+
- No longer exports `debugLog` but uses `console.log` directly only if `DEBUG` is available under `process.env`
7+

.changeset/pink-zoos-fold.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-tools/links': minor
3+
---
4+
5+
feat(links): Respect operationName

.changeset/polite-yaks-drive.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@graphql-tools/utils': major
3+
---
4+
5+
BREAKING CHANGE
6+
- No longer applies `camelCase` naming convention in `buildOperationNodeForField`

.changeset/silent-comics-tell.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@graphql-tools/schema': major
3+
---
4+
5+
BREAKING CHANGE
6+
- No longer exports `buildSchemaFromTypeDefinitions`, use `buildSchema` from `graphql-js` instead
7+
- Remove `allowUndefinedResolve` option in `makeExecutableSchema` because GraphQL Schema itself does this checking
8+

.changeset/smooth-tips-know.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@graphql-tools/utils': major
3+
---
4+
5+
BREAKING CHANGE
6+
- No longer exports `SchemaVisitor`, `visitSchema` and `VisitSchemaKind`
7+
- - Use [`mapSchema`](https://www.graphql-tools.com/docs/schema-directives/#full-mapschema-api) instead
8+

.changeset/twelve-suns-run.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-tools/schema': patch
3+
---
4+
5+
enhance(schema): use merge package to handle typeDefs and resolvers merging

.changeset/wicked-tables-beg.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-tools/utils': minor
3+
---
4+
5+
feat(utils): Respect operationName and rootValue in ExecutionParams

.changeset/young-beans-fail.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@graphql-tools/url-loader': major
3+
---
4+
5+
BREAKING CHANGE
6+
- No more accept arrays or functions for `headers`
7+
8+
NEW FEATURES
9+
- Respect `operationName` and `extensions`
10+
- Ability to get headers from `extensions.headers`

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
"packages/load/tests/loaders/schema",
6262
"website",
6363
"scripts",
64-
"packages/loaders/code-file/tests/test-files"
64+
"packages/loaders/code-file/tests/test-files",
65+
"packages/loaders/git/tests/test-files"
6566
],
6667
"globals":{
6768
"BigInt": true

.github/workflows/canary.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ on:
44
pull_request:
55
branches:
66
- master
7-
7+
workflow_dispatch:
8+
inputs:
9+
confirm:
10+
description: 'Are you sure?'
11+
required: true
12+
default: 'yes'
813
jobs:
914
publish-canary:
1015
name: Publish Canary
1116
runs-on: ubuntu-latest
12-
if: github.event.pull_request.head.repo.full_name == github.repository
17+
if: github.event.pull_request.head.repo.full_name == github.repository || github.event.inputs.confirm == 'yes'
1318
steps:
1419
- name: Checkout Master
1520
uses: actions/checkout@v2
@@ -44,6 +49,8 @@ jobs:
4449
npm-token: ${{ secrets.NODE_AUTH_TOKEN }}
4550
npm-script: 'yarn release:canary'
4651
changesets: true
52+
env:
53+
ON_DEMAND: ${{github.event.inputs.confirm}}
4754
- name: Publish a message
4855
if: steps.canary.outputs.released
4956
uses: 'kamilkisiela/pr-comment@master'

.github/workflows/tests.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Lint
3232
run: yarn lint
3333
build:
34-
name: Build on ${{matrix.os}} GraphQL v${{matrix.graphql_version}}
34+
name: Type Check on GraphQL v${{matrix.graphql_version}}
3535
runs-on: ubuntu-latest
3636
strategy:
3737
matrix:
@@ -55,14 +55,13 @@ jobs:
5555
- name: Install Dependencies using Yarn
5656
run: yarn install --ignore-engines && git checkout yarn.lock
5757
- name: Build
58-
run: yarn ts:transpile
58+
run: yarn ts:check
5959
test:
60-
name: Test on ${{matrix.os}}, Node ${{matrix.node_version}} and GraphQL v${{matrix.graphql_version}}
61-
runs-on: ${{matrix.os}}
60+
name: Unit Test on Node ${{matrix.node_version}} and GraphQL v${{matrix.graphql_version}}
61+
runs-on: ubuntu-latest
6262
strategy:
6363
matrix:
64-
os: [ubuntu-latest] # remove windows to speed up the tests
65-
node_version: [10, 16]
64+
node_version: [12, 16]
6665
graphql_version: [14, 15]
6766
steps:
6867
- name: Checkout Master

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"postinstall": "patch-package && husky install",
88
"predeploy:website": "yarn build:api-docs",
99
"deploy:website": "cd website && yarn deploy",
10-
"ts:transpile": "concurrently \"tsc --project tsconfig.build.json\" \"tsc --project tsconfig.build.es5.json\"",
10+
"ts:check": "tsc --noEmit --incremental",
11+
"ts:transpile": "concurrently \"tsc --project tsconfig.build.json --incremental\" \"tsc --project tsconfig.build.es5.json --incremental\"",
1112
"clean-dist": "rimraf \"packages/**/dist\" && rimraf \"packages/**/dist-es5\" && rimraf \".bob\"",
1213
"build": "yarn ts:transpile && bob build",
1314
"build:api-docs": "node scripts/build-api-docs.js",
@@ -45,14 +46,14 @@
4546
"bob-the-bundler": "1.4.1",
4647
"@babel/core": "7.14.6",
4748
"@babel/plugin-proposal-class-properties": "7.14.5",
48-
"@babel/preset-env": "7.14.5",
49+
"@babel/preset-env": "7.14.7",
4950
"@babel/preset-typescript": "7.14.5",
5051
"@changesets/cli": "2.16.0",
5152
"@types/jest": "26.0.23",
52-
"@types/node": "14.17.3",
53-
"@typescript-eslint/eslint-plugin": "4.27.0",
54-
"@typescript-eslint/parser": "4.27.0",
55-
"babel-jest": "27.0.2",
53+
"@types/node": "14.17.4",
54+
"@typescript-eslint/eslint-plugin": "4.28.0",
55+
"@typescript-eslint/parser": "4.28.0",
56+
"babel-jest": "27.0.5",
5657
"concurrently": "6.2.0",
5758
"eslint": "7.29.0",
5859
"eslint-config-prettier": "8.3.0",
@@ -65,7 +66,7 @@
6566
"graphql-helix": "1.6.1",
6667
"graphql-subscriptions": "1.2.1",
6768
"husky": "6.0.0",
68-
"jest": "27.0.4",
69+
"jest": "27.0.5",
6970
"lint-staged": "11.0.0",
7071
"nock": "13.1.0",
7172
"patch-package": "6.4.7",

packages/batch-delegate/src/batchDelegateToSchema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { BatchDelegateOptions } from './types';
22

33
import { getLoader } from './getLoader';
44

5-
export function batchDelegateToSchema(options: BatchDelegateOptions): any {
5+
export function batchDelegateToSchema<TContext = any>(options: BatchDelegateOptions<TContext>): any {
66
const key = options.key;
77
if (key == null) {
88
return null;

packages/batch-delegate/tests/basic.example.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ describe('batch delegation within basic stitching example', () => {
8989

9090
expect(numCalls).toEqual(1);
9191
expect(result.errors).toBeUndefined();
92-
expect(result.data!.trendingChirps[0].chirpedAtUser.email).not.toBe(null);
92+
expect(result.data!['trendingChirps'][0].chirpedAtUser.email).not.toBe(null);
9393
});
9494

9595
test('works with key arrays', async () => {

packages/batch-delegate/tests/typeMerging.example.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('merging using type merging', () => {
8484
Query: {
8585
mostStockedProduct: () => inventory.find(i => i.upc === '3'),
8686
_products: (_root, { representations }) => {
87-
return representations.map((rep: Record<string, any>) => ({ ...rep, ...inventory.find(i => i.upc === rep.upc) }));
87+
return representations.map((rep: Record<string, any>) => ({ ...rep, ...inventory.find(i => i.upc === rep['upc']) }));
8888
},
8989
},
9090
},

packages/batch-delegate/tests/withTransforms.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('works with complex transforms', () => {
7373
]
7474
}),
7575
resultTransformer: (results, delegationContext) => {
76-
const userIds = delegationContext.args.userIds;
76+
const userIds = delegationContext.args['userIds'];
7777
const booksByUserIds = results.reduce(
7878
(acc: any, { userId, books }: { userId: string, books: any[] }) => {
7979
acc[userId] = books

packages/batch-execute/src/createBatchingExecutor.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,18 @@ function createLoadFn(
5151
}
5252
}
5353

54-
const executionResults: Array<ValueOrPromise<ExecutionResult>> = [];
55-
execBatches.forEach(execBatch => {
54+
const executionResults: Array<ValueOrPromise<ExecutionResult>> = execBatches.map(execBatch => {
5655
const mergedExecutionParams = mergeExecutionParams(execBatch, extensionsReducer);
57-
executionResults.push(new ValueOrPromise(() => executor(mergedExecutionParams)));
56+
return new ValueOrPromise(() => executor(mergedExecutionParams));
5857
});
5958

6059
return ValueOrPromise.all(executionResults)
61-
.then(resultBatches => {
62-
let results: Array<ExecutionResult> = [];
63-
resultBatches.forEach((resultBatch, index) => {
64-
results = [...results, ...splitResult(resultBatch!, execBatches[index].length)];
65-
});
66-
return results;
67-
})
60+
.then(resultBatches =>
61+
resultBatches.reduce(
62+
(results, resultBatch, index) => results.concat(splitResult(resultBatch, execBatches[index].length)),
63+
new Array<ExecutionResult<Record<string, any>>>()
64+
)
65+
)
6866
.resolve();
6967
};
7068
}

packages/batch-execute/src/getBatchingExecutor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { createBatchingExecutor } from './createBatchingExecutor';
55
import { memoize2of4 } from './memoize';
66

77
export const getBatchingExecutor = memoize2of4(function (
8-
_context: Record<string, any> = self ?? window ?? global,
8+
_context: Record<string, any>,
99
executor: Executor,
1010
dataLoaderOptions?: DataLoader.Options<any, any, any> | undefined,
1111
extensionsReducer?:

packages/batch-execute/src/mergeExecutionParams.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,25 @@ export function mergeExecutionParams(
6868

6969
let operation: Maybe<OperationTypeNode>;
7070

71-
execs.forEach((executionParams, index) => {
71+
for (const index in execs) {
72+
const executionParams = execs[index];
7273
const prefixedExecutionParams = prefixExecutionParams(createPrefix(index), executionParams);
7374

74-
prefixedExecutionParams.document.definitions.forEach(def => {
75+
for (const def of prefixedExecutionParams.document.definitions) {
7576
if (isOperationDefinition(def)) {
7677
operation = def.operation;
7778
mergedSelections.push(...def.selectionSet.selections);
78-
mergedVariableDefinitions.push(...(def.variableDefinitions ?? []));
79+
if (def.variableDefinitions) {
80+
mergedVariableDefinitions.push(...def.variableDefinitions);
81+
}
7982
}
8083
if (isFragmentDefinition(def)) {
8184
mergedFragmentDefinitions.push(def);
8285
}
83-
});
86+
}
8487
Object.assign(mergedVariables, prefixedExecutionParams.variables);
8588
mergedExtensions = extensionsReducer(mergedExtensions, executionParams);
86-
});
89+
}
8790

8891
if (operation == null) {
8992
throw new Error('Could not identify operation type. Did the document only include fragment definitions?');

packages/batch-execute/src/prefix.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// adapted from https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-graphql/src/batching/merge-queries.js
22

3-
export function createPrefix(index: number): string {
3+
export function createPrefix(index: string): string {
44
return `graphqlTools${index}_`;
55
}
66

0 commit comments

Comments
 (0)