Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphiQL v4 #3685

Draft
wants to merge 66 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
fec285b
changeset pre enter alpha
dimaMachina Aug 7, 2024
3c1a345
[graphiql-react/graphiql] new looks of tabs (#3644)
dimaMachina Aug 7, 2024
5d90e0e
[2] GraphiQL x Vite v5 (#3679)
dimaMachina Aug 7, 2024
11aacd0
[3] remove unused webpack deps (#3681)
dimaMachina Aug 7, 2024
955573a
Merge branch 'main' into graphiql-v4
dimaMachina Aug 7, 2024
8efb873
[4] update graphql to `16.9.0` and use vite `define` configuration to…
dimaMachina Aug 7, 2024
0fdd9b9
remove `data-testid="graphiql-container"` (#3688)
dimaMachina Aug 7, 2024
c5b3aa2
commit `pre.json` until `graphiql-v4` will be added to list of author…
dimaMachina Aug 7, 2024
61fc27a
remove `graphiql-v4` from release.yml
dimaMachina Aug 7, 2024
09e7004
[v4] remove `disableTabs` option (#3687)
dimaMachina Aug 7, 2024
11bacb8
commit `pre.json`
dimaMachina Aug 7, 2024
445bf02
add `graphiql-v4` in release.yml
dimaMachina Aug 7, 2024
d34246e
Merge branch 'main' into graphiql-v4
dimaMachina Aug 7, 2024
82bc961
[v4] prefer `location` over `window.location` and prefer `navigator` …
dimaMachina Aug 7, 2024
93453fc
[v4] remove `build.sh` and `checkgit.sh` (#3694)
dimaMachina Aug 7, 2024
2005871
[v4] test umd build only on ci, locally test cdn.ts (#3693)
dimaMachina Aug 7, 2024
bf3ea52
[v4] convert graphiql e2e server to ESM (#3697)
dimaMachina Aug 8, 2024
bb70347
Merge branch 'main' into graphiql-v4
dimaMachina Aug 8, 2024
5e43d2b
[v4] update changeset for changed exports (#3700)
dimaMachina Aug 8, 2024
95668f5
Merge branch 'main' into graphiql-v4
dimaMachina Aug 8, 2024
00415d2
[v4] generate types with `vite-plugin-dts` (#3702)
dimaMachina Aug 9, 2024
8ff87d7
[v4] use `vite build --watch` instead of `vite` for `dev` script beca…
dimaMachina Aug 9, 2024
343dd59
[v4] remove graphiql default export (#3706)
dimaMachina Aug 9, 2024
4e26b74
Merge branch 'main' into graphiql-v4
dimaMachina Aug 9, 2024
db181b2
[v4] fix netlify deploy (#3708)
dimaMachina Aug 9, 2024
9baf1f0
change `style.css` imports (#3709)
dimaMachina Aug 9, 2024
7afb4be
Update poor-ghosts-jump.md
dimaMachina Aug 9, 2024
1a6d63d
Version Packages (alpha) (#3689)
acao Aug 11, 2024
27bbc51
[v4] show tabs even there is only 1 tab (#3713)
dimaMachina Aug 13, 2024
3c901c1
[v4] Remove `toolbar.additionalContent` and `toolbar.additionalCompon…
dimaMachina Aug 13, 2024
cb4553d
Version Packages (alpha) (#3714)
acao Aug 13, 2024
cc2808f
[v4] use `position: absolute` for `.graphiql-logo` class (#3716)
dimaMachina Aug 13, 2024
bf0c4e7
[v4] remove `createComponentGroup` utility in favour `Object.assign` …
dimaMachina Aug 13, 2024
15fff26
Version Packages (alpha) (#3718)
acao Aug 13, 2024
d3fc470
[v4] fix merge conflicts with `main` (#3719)
dimaMachina Aug 13, 2024
b468046
Merge branch 'main' into graphiql-v4
dimaMachina Aug 14, 2024
79f3abf
[v4] fix scrollbar appearing in sidebar (#3720)
dimaMachina Aug 14, 2024
9d28035
Version Packages (alpha) (#3723)
acao Aug 14, 2024
4609e00
Merge branch 'main' into graphiql-v4
dimaMachina Aug 14, 2024
6587675
Merge branch 'main' into graphiql-v4
dimaMachina Aug 14, 2024
f2a6b39
Merge branch 'main' into graphiql-v4
dimaMachina Aug 14, 2024
f8b719f
style: Don't convert single \n to <br> (#3414)
leonardehrenfried Aug 14, 2024
196e9a0
[v4] some refactoring (#3726)
dimaMachina Aug 14, 2024
3bcbda4
Merge branch 'main' into graphiql-v4
dimaMachina Aug 14, 2024
a1a5208
[v4] polish `tabs.cy` tests, remove `.graphiql-session` class (#3728)
dimaMachina Aug 14, 2024
99c64ac
Merge branch 'main' into graphiql-v4
dimaMachina Aug 15, 2024
167629f
fix tests
dimaMachina Aug 15, 2024
360a038
[v4] rollback `position: absolute` style for `.graphiql-logo` because…
dimaMachina Aug 15, 2024
8d9d469
Merge branch 'main' into graphiql-v4
dimaMachina Aug 15, 2024
fd0e25f
Version Packages (alpha) (#3725)
acao Aug 15, 2024
058d1d8
Merge branch 'main' into graphiql-v4
dimaMachina Aug 15, 2024
c966fa1
Merge branch 'main' into graphiql-v4
dimaMachina Aug 15, 2024
8dbddb5
Add support for onPrettifyQuery callback to enable customised query f…
dimaMachina Aug 15, 2024
e10e96c
Merge branch 'main' into graphiql-v4
dimaMachina Aug 15, 2024
3a2580e
Version Packages (alpha) (#3732)
acao Aug 15, 2024
eaa415c
[v4] improve explorer styles (#3738)
dimaMachina Aug 19, 2024
dfb302a
Version Packages (alpha) (#3739)
acao Aug 19, 2024
3c12ce0
fix types incorrect types entry (#3740)
dimaMachina Aug 20, 2024
e432fb5
Version Packages (alpha) (#3741)
acao Aug 20, 2024
ffaf5c9
add vite replace html plugin for graphiql plugin explorer (#3742)
dimaMachina Aug 20, 2024
f042025
Merge branch 'main' into graphiql-v4
dimaMachina Aug 22, 2024
befbd04
temp
dimaMachina Aug 23, 2024
fdcecaf
Merge branch 'main' into graphiql-v4
dimaMachina Aug 23, 2024
78cb500
migrate `@graphiql/toolkit` to `tsup` (#3746)
dimaMachina Aug 23, 2024
3c48be0
rollback of `temp` commit
dimaMachina Aug 23, 2024
068e23c
Merge branch 'main' into graphiql-v4
dimaMachina Aug 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[v4] prefer location over window.location and prefer navigator
…over `window.navigator` (#3692)
  • Loading branch information
dimaMachina committed Aug 7, 2024
commit 82bc961a33c4e9da29dffb4a603035a4909f49ad
7 changes: 7 additions & 0 deletions .changeset/spotty-bulldogs-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@graphiql/react': patch
'graphiql': patch
---

- prefer `location` over `window.location`
- prefer `navigator` over `window.navigator`
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ module.exports = {
property: 'localStorage',
message: 'Use `localStorage` instead',
},
{
object: 'window',
property: 'location',
message: 'Use `location` instead',
},
{
object: 'window',
property: 'navigator',
message: 'Use `navigator` instead',
},
],
'no-return-assign': 'error',
'no-return-await': 'error',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"scripts": {
"build": "yarn build-clean && yarn tsc && yarn build:nontsc",
"build-bundles": "yarn prebuild-bundles && yarn wsrun:noexamples --stages build-bundles",
"build-bundles-clean": "rimraf '{packages,examples,plugins}/**/{bundle,cdn,webpack}'",
"build-bundles-clean": "rimraf '{packages,examples}/**/{bundle,cdn,webpack}'",
"build-clean": "yarn tsc --clean",
"build-docs": "rimraf packages/graphiql/typedoc && typedoc packages",
"build:nontsc": "yarn wsrun:noexamples --exclude-missing --serial build",
Expand Down
12 changes: 5 additions & 7 deletions packages/graphiql-react/src/editor/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { KeyMap } from './types';
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;
}
const isMacOs =
typeof navigator !== 'undefined' &&
navigator.platform.toLowerCase().indexOf('mac') === 0;

export const commonKeys = {
// Persistent search box in Query Editor
Expand All @@ -30,10 +28,10 @@ export async function importCodeMirror(
addons: Promise<any>[],
options?: { useCommonAddons?: boolean },
) {
const CodeMirror = await import('codemirror').then(c =>
const CodeMirror = await import('codemirror').then(mod =>
// Depending on bundler and settings the dynamic import either returns a
// function (e.g. parcel) or an object containing a `default` property
typeof c === 'function' ? c : c.default,
typeof mod === 'function' ? mod : mod.default,
);
await Promise.all(
options?.useCommonAddons === false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,8 @@ function tokenToURL(token: Token) {
const value = token.string.slice(1).slice(0, -1).trim();

try {
const { location } = window;
return new URL(value, location.protocol + '//' + location.host);
} catch {
return;
}
} catch {}
}

function isImageURL(url: URL) {
Expand Down
30 changes: 15 additions & 15 deletions packages/graphiql/resources/renderExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// Parse the search string to get url parameters.
const parameters = {};
for (const entry of window.location.search.slice(1).split('&')) {
for (const entry of location.search.slice(1).split('&')) {
const eq = entry.indexOf('=');
if (eq >= 0) {
parameters[decodeURIComponent(entry.slice(0, eq))] = decodeURIComponent(
Expand Down Expand Up @@ -60,22 +60,22 @@ function updateURL() {
}

function getSchemaUrl() {
const isDev = window.location.hostname.match(/localhost$/);
const isDev = /localhost$/.test(location.hostname);

if (isDev) {
// This supports an e2e test which ensures that invalid schemas do not load.
if (parameters.bad === 'true') {
return '/bad/graphql';
}
if (parameters['http-error'] === 'true') {
return '/http-error/graphql';
}
if (parameters['graphql-error'] === 'true') {
return '/graphql-error/graphql';
}
return '/graphql';
if (!isDev) {
return '/.netlify/functions/graphql';
}
return '/.netlify/functions/graphql';
// This supports an e2e test which ensures that invalid schemas do not load.
if (parameters.bad === 'true') {
return '/bad/graphql';
}
if (parameters['http-error'] === 'true') {
return '/http-error/graphql';
}
if (parameters['graphql-error'] === 'true') {
return '/graphql-error/graphql';
}
return '/graphql';
}

// Render <GraphiQL /> into the body.
Expand Down
4 changes: 2 additions & 2 deletions packages/graphiql/src/components/GraphiQL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,8 @@
aria-controls="graphiql-session"
id={`graphiql-session-tab-${index}`}
onClick={() => {
executionContext.stop();
editorContext.changeTab(index);

Check warning on line 559 in packages/graphiql/src/components/GraphiQL.tsx

View check run for this annotation

Codecov / codecov/patch

packages/graphiql/src/components/GraphiQL.tsx#L558-L559

Added lines #L558 - L559 were not covered by tests
}}
>
{tab.title}
Expand Down Expand Up @@ -865,8 +865,8 @@
}

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

Expand Down
22 changes: 5 additions & 17 deletions packages/graphiql/test/images/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading