Skip to content

Commit

Permalink
Merge branch 'main' into sse
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina authored Aug 26, 2024
2 parents c35884d + a929862 commit 2936a79
Show file tree
Hide file tree
Showing 18 changed files with 61 additions and 31 deletions.
4 changes: 2 additions & 2 deletions examples/graphiql-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"@graphiql/plugin-code-exporter": "^3.1.2",
"@graphiql/plugin-explorer": "^3.2.2",
"@graphiql/toolkit": "^0.11.0",
"@graphiql/react": "^0.26.1",
"graphiql": "^3.7.0",
"@graphiql/react": "^0.26.2",
"graphiql": "^3.7.1",
"graphql": "^16.8.1",
"graphql-ws": "^5.5.5",
"react": "^18.2.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/cm6-graphql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# cm6-graphql

## 0.1.1

### Patch Changes

- [#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`

fix placeholder `⌘ K` in doc explorer search input for non mac devices, replace by `Ctrl K`

## 0.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cm6-graphql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cm6-graphql",
"version": "0.1.0",
"version": "0.1.1",
"description": "GraphQL language support for CodeMirror 6",
"scripts": {
"build": "cm-buildhelper src/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/cm6-graphql/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ export class Position implements IPosition {
}
}

const isMac = () => /mac/i.test(navigator.platform);
const isMac = () => navigator.userAgent.includes('Mac');
export const isMetaKeyPressed = (e: MouseEvent) =>
isMac() ? e.metaKey : e.ctrlKey;
8 changes: 8 additions & 0 deletions packages/codemirror-graphql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 2.1.1

### Patch Changes

- [#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`

fix placeholder `⌘ K` in doc explorer search input for non mac devices, replace by `Ctrl K`

## 2.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/codemirror-graphql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codemirror-graphql",
"version": "2.1.0",
"version": "2.1.1",
"description": "GraphQL mode and helpers for CodeMirror.",
"contributors": [
"Hyohyeon Jeong <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion packages/codemirror-graphql/src/utils/jump-addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function onKeyDown(cm: CodeMirror.Editor, event: KeyboardEvent) {
}

const isMac =
typeof navigator !== 'undefined' && navigator?.appVersion.includes('Mac');
typeof navigator !== 'undefined' && navigator.userAgent.includes('Mac');

function isJumpModifier(key: string) {
return key === (isMac ? 'Meta' : 'Control');
Expand Down
11 changes: 11 additions & 0 deletions packages/graphiql-react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @graphiql/react

## 0.26.2

### Patch Changes

- [#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`

fix placeholder `⌘ K` in doc explorer search input for non mac devices, replace by `Ctrl K`

- Updated dependencies [[`b8538d8`](https://github.com/graphql/graphiql/commit/b8538d87421edb086b32d4eb2e30a3f7d9d9e893)]:
- [email protected]

## 0.26.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/graphiql-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphiql/react",
"version": "0.26.1",
"version": "0.26.2",
"repository": {
"type": "git",
"url": "https://github.com/graphql/graphiql",
Expand Down Expand Up @@ -57,7 +57,7 @@
"@types/codemirror": "^5.60.8",
"clsx": "^1.2.1",
"codemirror": "^5.65.3",
"codemirror-graphql": "^2.1.0",
"codemirror-graphql": "^2.1.1",
"copy-to-clipboard": "^3.2.0",
"framer-motion": "^6.5.1",
"get-value": "^3.0.1",
Expand Down
7 changes: 1 addition & 6 deletions packages/graphiql-react/src/editor/common.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { KeyMap } from './types';
import { isMacOs } from '../utility/is-macos';

export const DEFAULT_EDITOR_THEME = 'graphiql';
export const DEFAULT_KEY_MAP: KeyMap = 'sublime';

let isMacOs = false;

if (typeof window === 'object') {
isMacOs = window.navigator.platform.toLowerCase().indexOf('mac') === 0;
}

export const commonKeys = {
// Persistent search box in Query Editor
[isMacOs ? 'Cmd-F' : 'Ctrl-F']: 'findPersistent',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

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

& [role='combobox']:focus {
Expand Down
3 changes: 2 additions & 1 deletion packages/graphiql-react/src/explorer/components/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useExplorerContext } from '../context';

import './search.css';
import { renderType } from './utils';
import { isMacOs } from '../../utility/is-macos';

export function Search() {
const { explorerNavStack, push } = useExplorerContext({
Expand Down Expand Up @@ -103,7 +104,7 @@ export function Search() {
onFocus={handleFocus}
onBlur={handleFocus}
onChange={event => setSearchValue(event.target.value)}
placeholder="&#x2318; K"
placeholder={`${isMacOs ? '⌘' : 'Ctrl'} K`}
ref={inputRef}
value={searchValue}
data-cy="doc-explorer-input"
Expand Down
1 change: 1 addition & 0 deletions packages/graphiql-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export {
} from './storage';
export { useTheme } from './theme';
export { useDragResize } from './utility/resize';
export { isMacOs } from './utility/is-macos';

export * from './icons';
export * from './ui';
Expand Down
2 changes: 2 additions & 0 deletions packages/graphiql-react/src/utility/is-macos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const isMacOs =
typeof navigator !== 'undefined' && navigator.userAgent.includes('Mac');
11 changes: 11 additions & 0 deletions packages/graphiql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## 3.7.1

### Patch Changes

- [#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`

fix placeholder `⌘ K` in doc explorer search input for non mac devices, replace by `Ctrl K`

- Updated dependencies [[`b8538d8`](https://github.com/graphql/graphiql/commit/b8538d87421edb086b32d4eb2e30a3f7d9d9e893)]:
- @graphiql/react@0.26.2

## 3.7.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/graphiql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphiql",
"version": "3.7.0",
"version": "3.7.1",
"description": "An graphical interactive in-browser GraphQL IDE.",
"contributors": [
"Hyohyeon Jeong <[email protected]>",
Expand Down Expand Up @@ -47,7 +47,7 @@
"webpack": "webpack-cli --config resources/webpack.config.js"
},
"dependencies": {
"@graphiql/react": "^0.26.1"
"@graphiql/react": "^0.26.2"
},
"peerDependencies": {
"graphql": "^15.5.0 || ^16.0.0 || ^17.0.0-alpha.2",
Expand Down
7 changes: 2 additions & 5 deletions packages/graphiql/src/components/GraphiQL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
UseVariableEditorArgs,
VariableEditor,
WriteableEditorProps,
isMacOs,
} from '@graphiql/react';

const majorVersion = parseInt(React.version.slice(0, 2), 10);
Expand Down Expand Up @@ -915,11 +916,7 @@ export function GraphiQLInterface(props: GraphiQLInterfaceProps) {
);
}

const modifier =
typeof window !== 'undefined' &&
window.navigator.platform.toLowerCase().indexOf('mac') === 0
? 'Cmd'
: 'Ctrl';
const modifier = isMacOs ? '⌘' : 'Ctrl';

const SHORT_KEYS = Object.entries({
'Search in editor': [modifier, 'F'],
Expand Down
12 changes: 4 additions & 8 deletions packages/graphiql/test/beforeDevServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ const path = require('node:path');
// eslint-disable-next-line import-x/no-extraneous-dependencies
const { createHandler } = require('graphql-http/lib/use/express');
const schema = require('./schema');
const badSchema = require('../cypress/fixtures/bad-schema.json');
const { customExecute } = require('./execute');

module.exports = function beforeDevServer(app, _server, _compiler) {
// GraphQL Server
app.post('/graphql', createHandler({ schema }));
app.get('/graphql', createHandler({ schema }));

app.post('/bad/graphql', (_req, res, next) => {
res.json({ data: badSchema });
next();
});
const handler = createHandler({ schema, execute: customExecute });
app.post('/graphql', handler);
app.get('/graphql', handler);

app.use('/images', express.static(path.join(__dirname, 'images')));

Expand Down

0 comments on commit 2936a79

Please sign in to comment.