Skip to content

Commit 5148707

Browse files
committed
Merge remote-tracking branch 'origin/main' into fd-gql-multiple-schema
2 parents 5dcd471 + a808019 commit 5148707

File tree

29 files changed

+358
-117
lines changed

29 files changed

+358
-117
lines changed

.changeset/curvy-balloons-allow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'graphiql': minor
3+
---
4+
5+
Allow disabling tabs and added new prop `disableTabs`

examples/graphiql-webpack/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
"start": "NODE_ENV=development webpack-cli serve"
1010
},
1111
"dependencies": {
12-
"@graphiql/plugin-code-exporter": "^0.3.5",
13-
"@graphiql/plugin-explorer": "^0.3.5",
12+
"@graphiql/plugin-code-exporter": "^1.0.3",
13+
"@graphiql/plugin-explorer": "^1.0.2",
1414
"@graphiql/toolkit": "^0.9.1",
15-
"@graphiql/react": "^0.19.4",
16-
"graphiql": "^3.0.6",
15+
"@graphiql/react": "^0.20.2",
16+
"graphiql": "^3.0.10",
1717
"graphql": "^16.4.0",
1818
"graphql-ws": "^5.5.5",
1919
"react": "^18.2.0",

packages/cm6-graphql/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# cm6-graphql
22

3+
## 0.0.12
4+
5+
### Patch Changes
6+
7+
- [#3463](https://github.com/graphql/graphiql/pull/3463) [`e45ba17c`](https://github.com/graphql/graphiql/commit/e45ba17cb2f13e5a79d3e87b0f30ef92ec55d861) Thanks [@imolorhe](https://github.com/imolorhe)! - Create a lint diagnostic from invalid schema
8+
9+
## 0.0.11
10+
11+
### Patch Changes
12+
13+
- [#3461](https://github.com/graphql/graphiql/pull/3461) [`129666a9`](https://github.com/graphql/graphiql/commit/129666a9a86690bb72226674d40215f24dc5f7ea) Thanks [@imolorhe](https://github.com/imolorhe)! - Wrap cm6-graphql lint logic in try..catch
14+
315
## 0.0.10
416

517
### Patch Changes

packages/cm6-graphql/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cm6-graphql",
3-
"version": "0.0.10",
3+
"version": "0.0.12",
44
"description": "GraphQL language support for CodeMirror 6",
55
"scripts": {
66
"build": "cm-buildhelper src/index.ts",

packages/cm6-graphql/src/interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { GraphQLSchema } from 'graphql';
44
import { ContextToken, CompletionItem } from 'graphql-language-service';
55
import { Position } from './helpers';
66
export interface GqlExtensionsOptions {
7+
showErrorOnInvalidSchema?: boolean;
78
onShowInDocs?: (field?: string, type?: string, parentType?: string) => void;
89
onFillAllFields?: (
910
view: EditorView,

packages/cm6-graphql/src/lint.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,44 @@
11
import { Diagnostic, linter } from '@codemirror/lint';
22
import { getDiagnostics } from 'graphql-language-service';
33
import { Position, posToOffset } from './helpers';
4-
import { getSchema, optionsStateField, schemaStateField } from './state';
4+
import {
5+
getOpts,
6+
getSchema,
7+
optionsStateField,
8+
schemaStateField,
9+
} from './state';
510
import { Extension } from '@codemirror/state';
11+
import { validateSchema } from 'graphql';
612

713
const SEVERITY = ['error', 'warning', 'info'] as const;
814

915
export const lint: Extension = linter(
1016
view => {
1117
const schema = getSchema(view.state);
18+
const options = getOpts(view.state);
1219
if (!schema) {
1320
return [];
1421
}
22+
const validationErrors = validateSchema(schema);
23+
if (validationErrors.length) {
24+
if (!options?.showErrorOnInvalidSchema) {
25+
return [];
26+
}
27+
28+
const combinedError = validationErrors.map(error => {
29+
return error.message;
30+
});
31+
32+
return [
33+
{
34+
from: 0,
35+
to: view.state.doc.length,
36+
severity: 'error',
37+
message: combinedError.join('\n'),
38+
actions: [], // TODO:
39+
},
40+
];
41+
}
1542
const results = getDiagnostics(view.state.doc.toString(), schema);
1643

1744
return results

packages/cm6-graphql/src/state.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ export const getOpts = (state: EditorState) => {
4949
return state.field(optionsStateField);
5050
};
5151

52+
const defaultOpts: GqlExtensionsOptions = {
53+
showErrorOnInvalidSchema: true,
54+
};
55+
5256
export const stateExtensions = (
5357
schema?: GraphQLSchema,
5458
opts?: GqlExtensionsOptions,
55-
) => [schemaStateField.init(() => schema), optionsStateField.init(() => opts)];
59+
) => [
60+
schemaStateField.init(() => schema),
61+
optionsStateField.init(() => ({ ...defaultOpts, ...opts })),
62+
];

packages/graphiql-plugin-code-exporter/CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
# @graphiql/plugin-code-exporter
22

3+
## 1.0.3
4+
5+
### Patch Changes
6+
7+
- [#3439](https://github.com/graphql/graphiql/pull/3439) [`d07d5fc0`](https://github.com/graphql/graphiql/commit/d07d5fc0cf764518bc1184ef168361cedf61540b) Thanks [@xonx4l](https://github.com/xonx4l)! - FIX: Unexpected duplicate CSS "display" property
8+
9+
## 1.0.2
10+
11+
### Patch Changes
12+
13+
- Updated dependencies [[`e89c432d`](https://github.com/graphql/graphiql/commit/e89c432d8d2b91f087b683360f23e0686462bc02)]:
14+
- @graphiql/react@0.20.2
15+
16+
## 1.0.1
17+
18+
### Patch Changes
19+
20+
- Updated dependencies [[`39bf31d1`](https://github.com/graphql/graphiql/commit/39bf31d15b1e7fb5f235ec9adc1ce8081536de4a)]:
21+
- @graphiql/react@0.20.1
22+
23+
## 1.0.0
24+
25+
### Patch Changes
26+
27+
- Updated dependencies [[`f6afd22d`](https://github.com/graphql/graphiql/commit/f6afd22d3f5a20089759042f16fd865646a32038)]:
28+
- @graphiql/react@0.20.0
29+
330
## 0.3.5
431

532
### Patch Changes

packages/graphiql-plugin-code-exporter/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@graphiql/plugin-code-exporter",
3-
"version": "0.3.5",
3+
"version": "1.0.3",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/graphql/graphiql",
@@ -33,13 +33,13 @@
3333
"graphiql-code-exporter": "^3.0.3"
3434
},
3535
"peerDependencies": {
36-
"@graphiql/react": "^0.19.4",
36+
"@graphiql/react": "^0.20.2",
3737
"graphql": "^15.5.0 || ^16.0.0",
3838
"react": "^16.8.0 || ^17 || ^18",
3939
"react-dom": "^16.8.0 || ^17 || ^18"
4040
},
4141
"devDependencies": {
42-
"@graphiql/react": "^0.19.4",
42+
"@graphiql/react": "^0.20.2",
4343
"@vitejs/plugin-react": "^4.0.1",
4444
"graphql": "^16.4.0",
4545
"postcss-nesting": "^10.1.7",

packages/graphiql-plugin-code-exporter/src/index.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
}
5050
}
5151
& button.toolbar-button {
52-
display: block;
5352
height: var(--toolbar-width) !important;
5453
width: var(--toolbar-width) !important;
5554
border-radius: var(--border-radius-4) !important;

0 commit comments

Comments
 (0)