Skip to content

Commit 6d039d3

Browse files
authored
UNION_MEMBER_ADDED is no longer a breaking change but dangerous (#1014)
1 parent 54a5dae commit 6d039d3

File tree

19 files changed

+42
-140
lines changed

19 files changed

+42
-140
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
### vNEXT
44

5-
- **core** **cli** introduce `keepClientFields` flag in `validate` [PR #783](https://github.com/kamilkisiela/graphql-inspector/pull/783)
5+
- **core** **cli**: introduce `keepClientFields` flag in `validate` [PR #783](https://github.com/kamilkisiela/graphql-inspector/pull/783)
6+
- **core**: `UNION_MEMBER_ADDED` is no longer a breaking change but dangerous
67

78
### v1.26.0
89

actions/cleanup/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"version": "1.0.0",
44
"license": "MIT",
55
"dependencies": {
6-
"actions-toolkit": "2.1.0"
6+
"actions-toolkit": "2.2.0"
77
}
88
}

actions/merged/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"version": "1.0.0",
44
"license": "MIT",
55
"dependencies": {
6-
"actions-toolkit": "2.1.0"
6+
"actions-toolkit": "2.2.0"
77
}
88
}

lib/action.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
"devDependencies": {
5252
"@types/express": "4.17.2",
5353
"@types/figures": "3.0.1",
54-
"@types/graphql": "14.5.0",
5554
"@types/indent-string": "4.0.1",
5655
"@types/jest": "24.0.25",
5756
"@types/log-symbols": "3.0.0",

packages/core/__tests__/diff/union.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('union', () => {
3737

3838
const change = findFirstChangeByPath(changes, 'Foo');
3939

40-
expect(change.criticality.level).toEqual(CriticalityLevel.Breaking);
40+
expect(change.criticality.level).toEqual(CriticalityLevel.Dangerous);
4141
expect(change.type).toEqual('UNION_MEMBER_ADDED');
4242
expect(change.message).toEqual("Member 'C' was added to Union type 'Foo'");
4343
});

packages/core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"dependency-graph": "0.8.1"
3434
},
3535
"devDependencies": {
36-
"@types/graphql": "14.5.0",
3736
"@types/jest": "24.0.25",
37+
"graphql": "14.5.8",
3838
"graphql-tag": "2.10.1",
3939
"jest": "24.9.0",
4040
"ts-jest": "24.2.0",

packages/core/src/diff/changes/union.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function unionMemberAdded(
2323
): Change {
2424
return {
2525
criticality: {
26-
level: CriticalityLevel.Breaking,
26+
level: CriticalityLevel.Dangerous,
2727
reason:
2828
'Adding a possible type to Unions may break existing clients that were not programming defensively against a new possible type.',
2929
},

packages/core/src/diff/enum.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export function changesInEnum(
1515
newEnum: GraphQLEnumType,
1616
): Change[] {
1717
const changes: Change[] = [];
18-
const oldNames = oldEnum.getValues().map(v => v.value);
19-
const newNames = newEnum.getValues().map(v => v.value);
18+
const oldNames = oldEnum.getValues().map(v => v.name);
19+
const newNames = newEnum.getValues().map(v => v.name);
2020

2121
const added = diffArrays(newNames, oldNames).map(
2222
name => newEnum.getValue(name) as GraphQLEnumValue,

packages/github-actions/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@
3535
"@actions/core": "1.2.0",
3636
"@actions/github": "2.0.0",
3737
"@graphql-inspector/github": "0.0.0-PLACEHOLDER",
38-
"actions-toolkit": "2.2.0",
3938
"graphql": "14.5.8",
4039
"js-yaml": "3.13.1",
4140
"probot": "9.8.0"
4241
},
4342
"devDependencies": {
44-
"@types/graphql": "14.5.0",
4543
"@types/js-yaml": "3.12.1",
4644
"@types/node": "13.1.2",
4745
"typescript": "3.7.4"

packages/github-actions/src/action.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
userAgent: 'node.js',
33
};
44

5-
import * as core from '@actions/core';
5+
import core from '@actions/core';
66
import {run} from './run';
77

88
run().catch(e => {

packages/github-actions/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22

3-
import * as core from '@actions/core';
3+
import core from '@actions/core';
44
import {run} from './run';
55

66
run().catch(e => {

packages/github-actions/src/run.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import {SchemaPointer} from '@graphql-inspector/github/dist/probot';
21
import {
2+
SchemaPointer,
33
ActionResult,
44
CheckConclusion,
55
Annotation,
6-
} from '@graphql-inspector/github/dist/types';
7-
import {diff} from '@graphql-inspector/github/dist/diff';
6+
diff,
7+
} from '@graphql-inspector/github';
88
import {buildSchema} from 'graphql';
99

10-
import * as core from '@actions/core';
11-
import * as github from '@actions/github';
10+
import core from '@actions/core';
11+
import github from '@actions/github';
1212
import {ChecksUpdateParams} from '@octokit/rest';
1313

1414
const CHECK_NAME = 'GraphQL Inspector';

packages/github/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
},
4343
"devDependencies": {
4444
"@types/express": "4.17.2",
45-
"@types/graphql": "14.5.0",
4645
"graphql": "14.5.8",
4746
"probot": "9.8.0",
4847
"smee-client": "1.1.0",

packages/github/src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ import appFn, {handleAction} from './probot';
22

33
export default appFn;
44
export {handleAction};
5+
export {ActionResult, CheckConclusion, Annotation} from './types';
6+
export {SchemaPointer} from './probot';
7+
export {diff} from './diff';

packages/load/src/documents.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import {Source, print} from 'graphql';
2-
import {loadDocumentsUsingLoaders} from '@graphql-toolkit/core';
2+
import {loadDocuments as toolkitLoadDocuments} from '@graphql-toolkit/core';
33
import {GraphQLFileLoader} from '@graphql-toolkit/graphql-file-loader';
44
import {CodeFileLoader} from '@graphql-toolkit/code-file-loader';
55

66
export async function loadDocuments(pointer: string): Promise<Source[]> {
7-
const documents = await loadDocumentsUsingLoaders(
8-
[new GraphQLFileLoader(), new CodeFileLoader()],
9-
pointer,
10-
);
7+
const documents = await toolkitLoadDocuments(pointer, {
8+
loaders: [new GraphQLFileLoader(), new CodeFileLoader()],
9+
});
1110

12-
return documents.map(doc => new Source(print(doc.document), doc.location));
11+
return documents.map(doc => new Source(print(doc.document!), doc.location));
1312
}

packages/load/src/schema/index.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {GraphQLSchema, isSchema} from 'graphql';
2-
import {loadSchemaUsingLoaders} from '@graphql-toolkit/core';
2+
import {loadSchema as toolkitLoadSchema} from '@graphql-toolkit/core';
33
import {GraphQLFileLoader} from '@graphql-toolkit/graphql-file-loader';
44
import {CodeFileLoader} from '@graphql-toolkit/code-file-loader';
55
import {GitLoader} from '@graphql-toolkit/git-loader';
@@ -11,18 +11,17 @@ export async function loadSchema(
1111
pointer: string,
1212
extra?: any,
1313
): Promise<GraphQLSchema> {
14-
const resolved = await loadSchemaUsingLoaders(
15-
[
14+
const resolved = await toolkitLoadSchema(pointer, {
15+
loaders: [
1616
new GitLoader(),
1717
new GithubLoader(),
1818
new GraphQLFileLoader(),
1919
new JsonFileLoader(),
2020
new UrlLoader(),
2121
new CodeFileLoader(),
2222
],
23-
pointer,
24-
extra || {},
25-
);
23+
...(extra || {}),
24+
});
2625

2726
if (isSchema(resolved)) {
2827
return resolved;

webpack.config.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@ module.exports = {
99
filename: 'action.js',
1010
},
1111
resolve: {
12-
extensions: ['.ts', '.ts', '.js', '.json'],
12+
extensions: ['.ts', '.js', '.json'],
1313
},
1414
module: {
1515
rules: [
1616
{
1717
test: /\.ts$/,
1818
exclude: /node_modules/,
1919
loader: 'ts-loader',
20+
options: {
21+
transpileOnly: true,
22+
},
2023
},
2124
{
2225
test: /\.mjs$/,
23-
include: /node_modules/,
2426
type: 'javascript/auto',
2527
},
2628
],

0 commit comments

Comments
 (0)