Skip to content

Commit 068e23c

Browse files
committed
Merge branch 'main' into graphiql-v4
2 parents 3c48be0 + a929862 commit 068e23c

File tree

39 files changed

+247
-143
lines changed

39 files changed

+247
-143
lines changed

.changeset/pretty-panthers-deliver.md

-5
This file was deleted.

.changeset/silent-ghosts-fix.md

-5
This file was deleted.

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ module.exports = {
343343
'unicorn/prefer-node-protocol': 'error',
344344
'import-x/no-unresolved': [
345345
'error',
346-
{ ignore: ['^node:', '\\.svg\\?react$'] },
346+
{ ignore: ['^node:', '\\.svg\\?react$', 'vitest/config'] },
347347
],
348348
'no-extra-boolean-cast': [
349349
'error',

examples/graphiql-webpack/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dependencies": {
1212
"@graphiql/plugin-code-exporter": "^4.0.0-alpha.1",
1313
"@graphiql/plugin-explorer": "^4.0.0-alpha.2",
14-
"@graphiql/toolkit": "^0.10.0",
14+
"@graphiql/toolkit": "^0.11.0",
1515
"@graphiql/react": "^1.0.0-alpha.4",
1616
"graphiql": "^4.0.0-alpha.5",
1717
"graphql": "^16.9.0",

examples/monaco-graphql-nextjs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"start": "next start"
1010
},
1111
"dependencies": {
12-
"@graphiql/toolkit": "^0.10.0",
12+
"@graphiql/toolkit": "^0.11.0",
1313
"graphql": "^16.9.0",
1414
"graphql-ws": "^5.5.5",
1515
"jsonc-parser": "^3.2.0",

examples/monaco-graphql-react-vite/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"private": true,
44
"version": "0.0.0",
55
"dependencies": {
6-
"@graphiql/toolkit": "^0.10.0",
6+
"@graphiql/toolkit": "^0.11.0",
77
"graphql": "^16.9.0",
88
"graphql-language-service": "^5.3.0",
99
"jsonc-parser": "^3.2.0",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
"ts-jest": "^27.1.5",
139139
"typedoc": "^0.19.2",
140140
"typescript": "^4.6.3",
141-
"vitest": "^2.0.4",
141+
"vitest": "^2.0.5",
142142
"wgutils": "^0.1.7",
143143
"wsrun": "^5.2.4"
144144
},

packages/cm6-graphql/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# cm6-graphql
22

3+
## 0.1.1
4+
5+
### Patch Changes
6+
7+
- [#3751](https://github.com/graphql/graphiql/pull/3751) [`b8538d8`](https://github.com/graphql/graphiql/commit/b8538d87421edb086b32d4eb2e30a3f7d9d9e893) Thanks [@dimaMachina](https://github.com/dimaMachina)! - replace deprecated `navigator.platform` with `navigator.userAgent`
8+
9+
fix placeholder `⌘ K` in doc explorer search input for non mac devices, replace by `Ctrl K`
10+
311
## 0.1.0
412

513
### Minor Changes

packages/cm6-graphql/package.json

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

packages/cm6-graphql/src/helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ export class Position implements IPosition {
3838
}
3939
}
4040

41-
const isMac = () => /mac/i.test(navigator.platform);
41+
const isMac = () => navigator.userAgent.includes('Mac');
4242
export const isMetaKeyPressed = (e: MouseEvent) =>
4343
isMac() ? e.metaKey : e.ctrlKey;

packages/codemirror-graphql/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change Log
22

3+
## 2.1.1
4+
5+
### Patch Changes
6+
7+
- [#3751](https://github.com/graphql/graphiql/pull/3751) [`b8538d8`](https://github.com/graphql/graphiql/commit/b8538d87421edb086b32d4eb2e30a3f7d9d9e893) Thanks [@dimaMachina](https://github.com/dimaMachina)! - replace deprecated `navigator.platform` with `navigator.userAgent`
8+
9+
fix placeholder `⌘ K` in doc explorer search input for non mac devices, replace by `Ctrl K`
10+
311
## 2.1.0
412

513
### Minor Changes

packages/codemirror-graphql/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codemirror-graphql",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "GraphQL mode and helpers for CodeMirror.",
55
"contributors": [
66
"Hyohyeon Jeong <[email protected]>",

packages/codemirror-graphql/src/utils/jump-addon.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function onKeyDown(cm: CodeMirror.Editor, event: KeyboardEvent) {
121121
}
122122

123123
const isMac =
124-
typeof navigator !== 'undefined' && navigator?.appVersion.includes('Mac');
124+
typeof navigator !== 'undefined' && navigator.userAgent.includes('Mac');
125125

126126
function isJumpModifier(key: string) {
127127
return key === (isMac ? 'Meta' : 'Control');

packages/graphiql-react/CHANGELOG.md

+20
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,26 @@
5656
- [#3692](https://github.com/graphql/graphiql/pull/3692) [`82bc961`](https://github.com/graphql/graphiql/commit/82bc961a33c4e9da29dffb4a603035a4909f49ad) Thanks [@dimaMachina](https://github.com/dimaMachina)! - - prefer `location` over `window.location`
5757
- prefer `navigator` over `window.navigator`
5858

59+
## 0.26.2
60+
61+
### Patch Changes
62+
63+
- [#3751](https://github.com/graphql/graphiql/pull/3751) [`b8538d8`](https://github.com/graphql/graphiql/commit/b8538d87421edb086b32d4eb2e30a3f7d9d9e893) Thanks [@dimaMachina](https://github.com/dimaMachina)! - replace deprecated `navigator.platform` with `navigator.userAgent`
64+
65+
fix placeholder `⌘ K` in doc explorer search input for non mac devices, replace by `Ctrl K`
66+
67+
- Updated dependencies [[`b8538d8`](https://github.com/graphql/graphiql/commit/b8538d87421edb086b32d4eb2e30a3f7d9d9e893)]:
68+
69+
70+
## 0.26.1
71+
72+
### Patch Changes
73+
74+
- [#3743](https://github.com/graphql/graphiql/pull/3743) [`7275c19`](https://github.com/graphql/graphiql/commit/7275c19b174f06bd031f49b33912c1babf29ccb0) Thanks [@dimaMachina](https://github.com/dimaMachina)! - create instance of `new HistoryStore` and `new StorageAPI` only on mount, use function with `useState`
75+
76+
- Updated dependencies [[`21c4409`](https://github.com/graphql/graphiql/commit/21c44096c0c0b23cea955a574d1110cb19ab6405), [`2ad4e75`](https://github.com/graphql/graphiql/commit/2ad4e7505385fefd252b9aa8ea2233cbaeca7f6a)]:
77+
- @graphiql/toolkit@0.11.0
78+
5979
## 0.26.0
6080

6181
### Minor Changes

packages/graphiql-react/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"react-dom": "^16.8.0 || ^17 || ^18"
4747
},
4848
"dependencies": {
49-
"@graphiql/toolkit": "^0.10.0",
49+
"@graphiql/toolkit": "^0.11.0",
5050
"@headlessui/react": "^1.7.15",
5151
"@radix-ui/react-dialog": "^1.0.4",
5252
"@radix-ui/react-dropdown-menu": "^2.0.5",
@@ -55,7 +55,7 @@
5555
"@types/codemirror": "^5.60.8",
5656
"clsx": "^1.2.1",
5757
"codemirror": "^5.65.3",
58-
"codemirror-graphql": "^2.1.0",
58+
"codemirror-graphql": "^2.1.1",
5959
"copy-to-clipboard": "^3.2.0",
6060
"framer-motion": "^10.0.0",
6161
"get-value": "^3.0.1",

packages/graphiql-react/src/editor/common.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import { KeyMap } from './types';
2+
import { isMacOs } from '../utility/is-macos';
23

34
export const DEFAULT_EDITOR_THEME = 'graphiql';
45
export const DEFAULT_KEY_MAP: KeyMap = 'sublime';
56

6-
const isMacOs =
7-
typeof navigator !== 'undefined' &&
8-
navigator.platform.toLowerCase().indexOf('mac') === 0;
9-
107
export const commonKeys = {
118
// Persistent search box in Query Editor
129
[isMacOs ? 'Cmd-F' : 'Ctrl-F']: 'findPersistent',

packages/graphiql-react/src/explorer/components/doc-explorer.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
&:not(:focus-within) [role='combobox'] {
4040
height: 24px;
41-
width: 4ch;
41+
width: 5ch;
4242
}
4343

4444
& [role='combobox']:focus {

packages/graphiql-react/src/explorer/components/search.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { useExplorerContext } from '../context';
2424

2525
import './search.css';
2626
import { renderType } from './utils';
27+
import { isMacOs } from '../../utility/is-macos';
2728

2829
export function Search() {
2930
const { explorerNavStack, push } = useExplorerContext({
@@ -103,7 +104,7 @@ export function Search() {
103104
onFocus={handleFocus}
104105
onBlur={handleFocus}
105106
onChange={event => setSearchValue(event.target.value)}
106-
placeholder="&#x2318; K"
107+
placeholder={`${isMacOs ? '⌘' : 'Ctrl'} K`}
107108
ref={inputRef}
108109
value={searchValue}
109110
data-cy="doc-explorer-input"

packages/graphiql-react/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export {
7171
} from './storage';
7272
export { useTheme } from './theme';
7373
export { useDragResize } from './utility/resize';
74+
export { isMacOs } from './utility/is-macos';
7475

7576
export * from './icons';
7677
export * from './ui';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const isMacOs =
2+
typeof navigator !== 'undefined' && navigator.userAgent.includes('Mac');

packages/graphiql-toolkit/CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# @graphiql/toolkit
22

3+
## 0.11.0
4+
5+
### Minor Changes
6+
7+
- [#3747](https://github.com/graphql/graphiql/pull/3747) [`21c4409`](https://github.com/graphql/graphiql/commit/21c44096c0c0b23cea955a574d1110cb19ab6405) Thanks [@dimaMachina](https://github.com/dimaMachina)! - do not include `require` statements in ESM build, include `import` in esm and `require` in cjs builds
8+
9+
make `getWsFetcher`, `createWebsocketsFetcherFromUrl` async
10+
11+
- [#3746](https://github.com/graphql/graphiql/pull/3746) [`2ad4e75`](https://github.com/graphql/graphiql/commit/2ad4e7505385fefd252b9aa8ea2233cbaeca7f6a) Thanks [@dimaMachina](https://github.com/dimaMachina)! - compile with `tsup` instead of `tsc`
12+
313
## 0.10.0
414

515
### Minor Changes

packages/graphiql-toolkit/jest.config.js

-5
This file was deleted.

packages/graphiql-toolkit/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@graphiql/toolkit",
3-
"version": "0.10.0",
3+
"version": "0.11.0",
44
"description": "Utility to build a fetcher for GraphiQL",
55
"contributors": [
66
"Rikki Schulte <[email protected]> (https://rikki.dev)"
@@ -22,7 +22,8 @@
2222
"build": "tsup",
2323
"dev": "tsup --watch",
2424
"prebuild": "yarn types:check",
25-
"types:check": "tsc --noEmit"
25+
"types:check": "tsc --noEmit",
26+
"test": "vitest run"
2627
},
2728
"dependencies": {
2829
"@n1ru4l/push-pull-async-iterable-iterator": "^3.1.0",

packages/graphiql-toolkit/src/create-fetcher/__tests__/buildFetcher.spec.ts

+37-10
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,54 @@
1+
import { Mock } from 'vitest';
12
import { parse, getIntrospectionQuery } from 'graphql';
23
import { createGraphiQLFetcher } from '../createFetcher';
34

45
import 'isomorphic-fetch';
56

6-
jest.mock('../lib');
7+
vi.mock('../lib');
78

8-
jest.mock('graphql-ws');
9+
vi.mock('graphql-ws');
910

10-
jest.mock('subscriptions-transport-ws');
11+
vi.mock('subscriptions-transport-ws');
1112

1213
import {
13-
createWebsocketsFetcherFromUrl,
14-
createMultipartFetcher,
15-
createSimpleFetcher,
16-
createWebsocketsFetcherFromClient,
17-
createLegacyWebsocketsFetcher,
14+
createWebsocketsFetcherFromUrl as _createWebsocketsFetcherFromUrl,
15+
createMultipartFetcher as _createMultipartFetcher,
16+
createSimpleFetcher as _createSimpleFetcher,
17+
createWebsocketsFetcherFromClient as _createWebsocketsFetcherFromClient,
18+
createLegacyWebsocketsFetcher as _createLegacyWebsocketsFetcher,
1819
} from '../lib';
19-
import { createClient } from 'graphql-ws';
20+
import { createClient as _createClient } from 'graphql-ws';
2021
import { SubscriptionClient } from 'subscriptions-transport-ws';
2122

2223
const serverURL = 'http://localhost:3000/graphql';
2324
const wssURL = 'ws://localhost:3000/graphql';
2425

2526
const exampleIntrospectionDocument = parse(getIntrospectionQuery());
2627

28+
const createWebsocketsFetcherFromUrl = _createWebsocketsFetcherFromUrl as Mock<
29+
typeof _createWebsocketsFetcherFromUrl
30+
>;
31+
const createMultipartFetcher = _createMultipartFetcher as Mock<
32+
typeof _createMultipartFetcher
33+
>;
34+
const createSimpleFetcher = _createSimpleFetcher as Mock<
35+
typeof _createSimpleFetcher
36+
>;
37+
const createClient = _createClient as Mock<typeof _createClient>;
38+
const createWebsocketsFetcherFromClient =
39+
_createWebsocketsFetcherFromClient as Mock<
40+
typeof _createWebsocketsFetcherFromClient
41+
>;
42+
const createLegacyWebsocketsFetcher = _createLegacyWebsocketsFetcher as Mock<
43+
typeof _createLegacyWebsocketsFetcher
44+
>;
45+
2746
describe('createGraphiQLFetcher', () => {
2847
afterEach(() => {
29-
jest.resetAllMocks();
48+
vi.resetAllMocks();
3049
});
3150
it('returns fetcher without websocket client by default', () => {
51+
// @ts-expect-error
3252
createWebsocketsFetcherFromUrl.mockReturnValue(true);
3353
createGraphiQLFetcher({ url: serverURL });
3454
expect(createWebsocketsFetcherFromUrl.mock.calls).toEqual([]);
@@ -38,6 +58,7 @@ describe('createGraphiQLFetcher', () => {
3858
});
3959

4060
it('returns simple fetcher for introspection', async () => {
61+
// @ts-expect-error
4162
createSimpleFetcher.mockReturnValue(async () => 'hey!');
4263
const fetcher = createGraphiQLFetcher({ url: serverURL });
4364
expect(createWebsocketsFetcherFromUrl.mock.calls).toEqual([]);
@@ -54,6 +75,7 @@ describe('createGraphiQLFetcher', () => {
5475
expect(res).toEqual('hey!');
5576
});
5677
it('returns fetcher without websocket client or multipart', () => {
78+
// @ts-expect-error
5779
createWebsocketsFetcherFromUrl.mockReturnValue(true);
5880
createGraphiQLFetcher({ url: serverURL, enableIncrementalDelivery: false });
5981
expect(createWebsocketsFetcherFromUrl.mock.calls).toEqual([]);
@@ -63,6 +85,7 @@ describe('createGraphiQLFetcher', () => {
6385
]);
6486
});
6587
it('returns fetcher with websocket client', () => {
88+
// @ts-expect-error
6689
createWebsocketsFetcherFromUrl.mockReturnValue('Client1');
6790

6891
const args = {
@@ -77,7 +100,9 @@ describe('createGraphiQLFetcher', () => {
77100
});
78101

79102
it('returns fetcher with custom wsClient', () => {
103+
// @ts-expect-error
80104
createClient.mockReturnValue('WSClient');
105+
// @ts-expect-error
81106
createWebsocketsFetcherFromUrl.mockReturnValue('CustomWSSFetcher');
82107

83108
const wsClient = createClient({ url: wssURL });
@@ -94,7 +119,9 @@ describe('createGraphiQLFetcher', () => {
94119
});
95120

96121
it('returns fetcher with custom legacyClient', () => {
122+
// @ts-expect-error
97123
createClient.mockReturnValue('WSClient');
124+
// @ts-expect-error
98125
createLegacyWebsocketsFetcher.mockReturnValue('CustomWSSFetcher');
99126

100127
const legacyClient = new SubscriptionClient(wssURL);

0 commit comments

Comments
 (0)