Skip to content

Commit

Permalink
Huge cleanup before major release (breaking) (#3081)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ardatan committed Jun 24, 2021
1 parent 806faae commit 7d3e300
Show file tree
Hide file tree
Showing 232 changed files with 2,621 additions and 7,870 deletions.
8 changes: 8 additions & 0 deletions .changeset/blue-phones-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@graphql-tools/delegate': major
---

BREAKING CHANGE
- Remove `rootValue` from subschemaConfig
- - Pass it through `ExecutionParams` or delegation options
- Do not pass `info.rootValue` if `rootValue` is falsy
7 changes: 7 additions & 0 deletions .changeset/brave-rats-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@graphql-tools/wrap': major
---

BREAKING CHANGE
- `makeRemoteExecutableSchema` has been removed.
- - You can use [`wrapSchema`](https://www.graphql-tools.com/docs/remote-schemas#creating-an-executor) instead
7 changes: 7 additions & 0 deletions .changeset/cuddly-horses-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@graphql-tools/utils': major
---

BREAKING CHANGE
- Remove `fieldToFieldConfig`, `argsToFieldConfigArgument` and `argumentToArgumentConfig`
- - You can use `.toConfig` method instead for each.
10 changes: 10 additions & 0 deletions .changeset/forty-ducks-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@graphql-tools/schema': major
'@graphql-tools/stitch': major
'@graphql-tools/utils': major
---

BREAKING CHANGE
- Legacy Schema Directives and Directive Resolvers have been removed
- - You can check the new method for both;
- - - https://www.graphql-tools.com/docs/schema-directives
8 changes: 8 additions & 0 deletions .changeset/heavy-vans-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@graphql-tools/schema': major
---

BREAKING CHANGE
- Remove `logger` and `addErrorLoggingToSchema`
- - 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)

7 changes: 7 additions & 0 deletions .changeset/long-rings-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'graphql-tools': major
---

BREAKING CHANGE
- Now it only exports `makeExecutableSchema` from `@graphql-tools/schema`
- Please migrate to scoped packages(`@graphql-tools/*`) because this npm package will no longer get updated
15 changes: 15 additions & 0 deletions .changeset/mean-news-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@graphql-tools/delegate': major
'@graphql-tools/apollo-engine-loader': major
'@graphql-tools/utils': major
'@graphql-tools/wrap': major
---

BREAKING CHANGE
- 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`.
```js
// From;
for (const error of aggregateError)
// To;
for (const error of aggregateError.errors)
```
8 changes: 8 additions & 0 deletions .changeset/new-balloons-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@graphql-tools/schema': major
---

BREAKING CHANGE
- Remove schema level resolvers feature and `addSchemaLevelResolver`
- - You can wrap your resolvers by using [Resolvers Composition](https://www.graphql-tools.com/docs/resolvers-composition)

7 changes: 7 additions & 0 deletions .changeset/ninety-shirts-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@graphql-tools/utils': major
---

BREAKING CHANGE
- No longer exports `debugLog` but uses `console.log` directly only if `DEBUG` is available under `process.env`

5 changes: 5 additions & 0 deletions .changeset/pink-zoos-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/links': minor
---

feat(links): Respect operationName
6 changes: 6 additions & 0 deletions .changeset/polite-yaks-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@graphql-tools/utils': major
---

BREAKING CHANGE
- No longer applies `camelCase` naming convention in `buildOperationNodeForField`
8 changes: 8 additions & 0 deletions .changeset/silent-comics-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@graphql-tools/schema': major
---

BREAKING CHANGE
- No longer exports `buildSchemaFromTypeDefinitions`, use `buildSchema` from `graphql-js` instead
- Remove `allowUndefinedResolve` option in `makeExecutableSchema` because GraphQL Schema itself does this checking

8 changes: 8 additions & 0 deletions .changeset/smooth-tips-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@graphql-tools/utils': major
---

BREAKING CHANGE
- No longer exports `SchemaVisitor`, `visitSchema` and `VisitSchemaKind`
- - Use [`mapSchema`](https://www.graphql-tools.com/docs/schema-directives/#full-mapschema-api) instead

5 changes: 5 additions & 0 deletions .changeset/twelve-suns-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/schema': patch
---

enhance(schema): use merge package to handle typeDefs and resolvers merging
5 changes: 5 additions & 0 deletions .changeset/wicked-tables-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/utils': minor
---

feat(utils): Respect operationName and rootValue in ExecutionParams
10 changes: 10 additions & 0 deletions .changeset/young-beans-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@graphql-tools/url-loader': major
---

BREAKING CHANGE
- No more accept arrays or functions for `headers`

NEW FEATURES
- Respect `operationName` and `extensions`
- Ability to get headers from `extensions.headers`
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"packages/load/tests/loaders/schema",
"website",
"scripts",
"packages/loaders/code-file/tests/test-files"
"packages/loaders/code-file/tests/test-files",
"packages/loaders/git/tests/test-files"
],
"globals":{
"BigInt": true
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ on:
pull_request:
branches:
- master

workflow_dispatch:
inputs:
confirm:
description: 'Are you sure?'
required: true
default: 'yes'
jobs:
publish-canary:
name: Publish Canary
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository
if: github.event.pull_request.head.repo.full_name == github.repository || github.event.inputs.confirm == 'yes'
steps:
- name: Checkout Master
uses: actions/checkout@v2
Expand Down Expand Up @@ -44,6 +49,8 @@ jobs:
npm-token: ${{ secrets.NODE_AUTH_TOKEN }}
npm-script: 'yarn release:canary'
changesets: true
env:
ON_DEMAND: ${{github.event.inputs.confirm}}
- name: Publish a message
if: steps.canary.outputs.released
uses: 'kamilkisiela/pr-comment@master'
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Lint
run: yarn lint
build:
name: Build on ${{matrix.os}} GraphQL v${{matrix.graphql_version}}
name: Type Check on GraphQL v${{matrix.graphql_version}}
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -55,14 +55,13 @@ jobs:
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
- name: Build
run: yarn ts:transpile
run: yarn ts:check
test:
name: Test on ${{matrix.os}}, Node ${{matrix.node_version}} and GraphQL v${{matrix.graphql_version}}
runs-on: ${{matrix.os}}
name: Unit Test on Node ${{matrix.node_version}} and GraphQL v${{matrix.graphql_version}}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest] # remove windows to speed up the tests
node_version: [10, 16]
node_version: [12, 16]
graphql_version: [14, 15]
steps:
- name: Checkout Master
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"postinstall": "patch-package && husky install",
"predeploy:website": "yarn build:api-docs",
"deploy:website": "cd website && yarn deploy",
"ts:transpile": "concurrently \"tsc --project tsconfig.build.json\" \"tsc --project tsconfig.build.es5.json\"",
"ts:check": "tsc --noEmit --incremental",
"ts:transpile": "concurrently \"tsc --project tsconfig.build.json --incremental\" \"tsc --project tsconfig.build.es5.json --incremental\"",
"clean-dist": "rimraf \"packages/**/dist\" && rimraf \"packages/**/dist-es5\" && rimraf \".bob\"",
"build": "yarn ts:transpile && bob build",
"build:api-docs": "node scripts/build-api-docs.js",
Expand Down Expand Up @@ -45,14 +46,14 @@
"bob-the-bundler": "1.4.1",
"@babel/core": "7.14.6",
"@babel/plugin-proposal-class-properties": "7.14.5",
"@babel/preset-env": "7.14.5",
"@babel/preset-env": "7.14.7",
"@babel/preset-typescript": "7.14.5",
"@changesets/cli": "2.16.0",
"@types/jest": "26.0.23",
"@types/node": "14.17.3",
"@typescript-eslint/eslint-plugin": "4.27.0",
"@typescript-eslint/parser": "4.27.0",
"babel-jest": "27.0.2",
"@types/node": "14.17.4",
"@typescript-eslint/eslint-plugin": "4.28.0",
"@typescript-eslint/parser": "4.28.0",
"babel-jest": "27.0.5",
"concurrently": "6.2.0",
"eslint": "7.29.0",
"eslint-config-prettier": "8.3.0",
Expand All @@ -65,7 +66,7 @@
"graphql-helix": "1.6.1",
"graphql-subscriptions": "1.2.1",
"husky": "6.0.0",
"jest": "27.0.4",
"jest": "27.0.5",
"lint-staged": "11.0.0",
"nock": "13.1.0",
"patch-package": "6.4.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/batch-delegate/src/batchDelegateToSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BatchDelegateOptions } from './types';

import { getLoader } from './getLoader';

export function batchDelegateToSchema(options: BatchDelegateOptions): any {
export function batchDelegateToSchema<TContext = any>(options: BatchDelegateOptions<TContext>): any {
const key = options.key;
if (key == null) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion packages/batch-delegate/tests/basic.example.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('batch delegation within basic stitching example', () => {

expect(numCalls).toEqual(1);
expect(result.errors).toBeUndefined();
expect(result.data!.trendingChirps[0].chirpedAtUser.email).not.toBe(null);
expect(result.data!['trendingChirps'][0].chirpedAtUser.email).not.toBe(null);
});

test('works with key arrays', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/batch-delegate/tests/typeMerging.example.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('merging using type merging', () => {
Query: {
mostStockedProduct: () => inventory.find(i => i.upc === '3'),
_products: (_root, { representations }) => {
return representations.map((rep: Record<string, any>) => ({ ...rep, ...inventory.find(i => i.upc === rep.upc) }));
return representations.map((rep: Record<string, any>) => ({ ...rep, ...inventory.find(i => i.upc === rep['upc']) }));
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/batch-delegate/tests/withTransforms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('works with complex transforms', () => {
]
}),
resultTransformer: (results, delegationContext) => {
const userIds = delegationContext.args.userIds;
const userIds = delegationContext.args['userIds'];
const booksByUserIds = results.reduce(
(acc: any, { userId, books }: { userId: string, books: any[] }) => {
acc[userId] = books
Expand Down
18 changes: 8 additions & 10 deletions packages/batch-execute/src/createBatchingExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,18 @@ function createLoadFn(
}
}

const executionResults: Array<ValueOrPromise<ExecutionResult>> = [];
execBatches.forEach(execBatch => {
const executionResults: Array<ValueOrPromise<ExecutionResult>> = execBatches.map(execBatch => {
const mergedExecutionParams = mergeExecutionParams(execBatch, extensionsReducer);
executionResults.push(new ValueOrPromise(() => executor(mergedExecutionParams)));
return new ValueOrPromise(() => executor(mergedExecutionParams));
});

return ValueOrPromise.all(executionResults)
.then(resultBatches => {
let results: Array<ExecutionResult> = [];
resultBatches.forEach((resultBatch, index) => {
results = [...results, ...splitResult(resultBatch!, execBatches[index].length)];
});
return results;
})
.then(resultBatches =>
resultBatches.reduce(
(results, resultBatch, index) => results.concat(splitResult(resultBatch, execBatches[index].length)),
new Array<ExecutionResult<Record<string, any>>>()
)
)
.resolve();
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/batch-execute/src/getBatchingExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createBatchingExecutor } from './createBatchingExecutor';
import { memoize2of4 } from './memoize';

export const getBatchingExecutor = memoize2of4(function (
_context: Record<string, any> = self ?? window ?? global,
_context: Record<string, any>,
executor: Executor,
dataLoaderOptions?: DataLoader.Options<any, any, any> | undefined,
extensionsReducer?:
Expand Down
13 changes: 8 additions & 5 deletions packages/batch-execute/src/mergeExecutionParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,25 @@ export function mergeExecutionParams(

let operation: Maybe<OperationTypeNode>;

execs.forEach((executionParams, index) => {
for (const index in execs) {
const executionParams = execs[index];
const prefixedExecutionParams = prefixExecutionParams(createPrefix(index), executionParams);

prefixedExecutionParams.document.definitions.forEach(def => {
for (const def of prefixedExecutionParams.document.definitions) {
if (isOperationDefinition(def)) {
operation = def.operation;
mergedSelections.push(...def.selectionSet.selections);
mergedVariableDefinitions.push(...(def.variableDefinitions ?? []));
if (def.variableDefinitions) {
mergedVariableDefinitions.push(...def.variableDefinitions);
}
}
if (isFragmentDefinition(def)) {
mergedFragmentDefinitions.push(def);
}
});
}
Object.assign(mergedVariables, prefixedExecutionParams.variables);
mergedExtensions = extensionsReducer(mergedExtensions, executionParams);
});
}

if (operation == null) {
throw new Error('Could not identify operation type. Did the document only include fragment definitions?');
Expand Down
2 changes: 1 addition & 1 deletion packages/batch-execute/src/prefix.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// adapted from https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-graphql/src/batching/merge-queries.js

export function createPrefix(index: number): string {
export function createPrefix(index: string): string {
return `graphqlTools${index}_`;
}

Expand Down
Loading

0 comments on commit 7d3e300

Please sign in to comment.