Skip to content

[graphiql]: support react 19, drop support react 16 and react 17 #3897

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

Draft
wants to merge 34 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1b6b507
upd
dimaMachina Apr 26, 2025
84ec2f8
upd
dimaMachina Apr 26, 2025
b3cc341
upd
dimaMachina Apr 26, 2025
178e594
upd
dimaMachina Apr 26, 2025
942afb1
upd
dimaMachina Apr 26, 2025
84b9983
exclude react-dom/client from bundle
dimaMachina Apr 26, 2025
e394bb6
bump react everywhere to v19
dimaMachina Apr 26, 2025
b2eb509
bump react everywhere to v19
dimaMachina Apr 26, 2025
58d9607
polish
dimaMachina Apr 26, 2025
9b0d339
fix failing text, to unblock canary
dimaMachina Apr 26, 2025
54b0dee
Merge branch 'main' into react19
dimaMachina Apr 26, 2025
3f3dc5e
upd
dimaMachina Apr 26, 2025
c58df79
Merge branch 'main' into react19
dimaMachina Apr 26, 2025
efc7c3f
try `minor` for graphiql/react, otherwise it pines to `1.0.0-next.2` …
dimaMachina Apr 26, 2025
07a0905
try workaround
dimaMachina Apr 26, 2025
c3b73f3
try workaround
dimaMachina Apr 26, 2025
adbdb8f
try workaround
dimaMachina Apr 26, 2025
a408e42
try workaround
dimaMachina Apr 26, 2025
4b34b10
this should fix vitest
dimaMachina Apr 26, 2025
284c2fa
try
dimaMachina Apr 27, 2025
2382b03
try
dimaMachina Apr 27, 2025
5242c56
lint
dimaMachina Apr 27, 2025
46b304f
try
dimaMachina Apr 27, 2025
6325cda
fix test
dimaMachina Apr 27, 2025
efbd430
try SOURCEMAP var
dimaMachina Apr 27, 2025
c1ab45d
try ESM_SH_BUILD var
dimaMachina Apr 27, 2025
d23559f
try
dimaMachina Apr 27, 2025
1b248df
rm some unneeded code
dimaMachina Apr 27, 2025
6fc5225
try to fix esbuild: package 'uWebSockets.js' not found
dimaMachina Apr 27, 2025
1d41eb0
update vite to see if it fix esbuild error?
dimaMachina Apr 27, 2025
cb95709
bump module "@emotion/is-prop-valid" not found to fix `module "@emoti…
dimaMachina Apr 28, 2025
9e856e6
upd
dimaMachina Apr 28, 2025
9efda10
upd
dimaMachina Apr 28, 2025
0f373b9
upd
dimaMachina Apr 28, 2025
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
10 changes: 10 additions & 0 deletions .changeset/gold-cooks-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@graphiql/plugin-code-exporter': major
'@graphiql/plugin-explorer': major
'@graphiql/react': minor
'graphiql': major
---

- support react 19, drop support react 16 and react 17
- replace deprecated `ReactDOM.unmountComponentAtNode()` and `ReactDOM.render()` with `root.unmount()` and `createRoot(container).render()`
- update `@radix-ui` dependencies
17 changes: 12 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ module.exports = {
excludedFiles: ['**/*.{md,mdx}/*.{ts,tsx}'],
// extends: ['plugin:@typescript-eslint/recommended-type-checked'],
rules: {
// '@typescript-eslint/no-redundant-type-constituents': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-floating-promises': 'error',
Expand All @@ -388,11 +389,10 @@ module.exports = {
projectService: {
allowDefaultProject: [
'examples/monaco-graphql-react-vite/vite.config.ts',
'packages/*/vitest.config.mts',
'packages/*/vite.config.mts',
'packages/{graphiql,graphiql-plugin-explorer,graphiql-plugin-code-exporter}/vite.config.mts',
'packages/{codemirror-graphql,graphiql-toolkit,graphql-language-service-cli,graphql-language-service,monaco-graphql,vscode-graphql-syntax,graphiql}/vitest.config.mts',

'packages/cm6-graphql/__tests__/test.spec.ts',
'packages/graphiql-react/setup-files.ts',
'packages/graphiql/src/GraphiQL.spec.tsx',
'packages/vscode-graphql-syntax/tests/*.spec.ts',
'packages/graphql-language-service-cli/src/__tests__/*.test.ts',
Expand Down Expand Up @@ -483,15 +483,15 @@ module.exports = {
},
},
{
// Rule prefer await to then without React packages because it's ugly to have `async IIFE` inside `useEffect`
// Rule to prefer await to then without React packages because it's ugly to have `async IIFE` inside `useEffect`
files: ['packages/**'],
excludedFiles: ['packages/graphiql/**', 'packages/graphiql-react/**'],
rules: {
'promise/prefer-await-to-then': 'error',
},
},
{
files: ['packages/{graphiql-react,graphiql}/**'],
files: ['packages/{graphiql-react,graphiql}/**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-restricted-imports': [
'error',
Expand All @@ -502,6 +502,7 @@ module.exports = {
},
],
'react-hooks/react-compiler': 'error',
'@typescript-eslint/no-deprecated': 'error',
},
},
{
Expand Down Expand Up @@ -529,6 +530,12 @@ module.exports = {
'mdx/code-blocks': true,
},
},
{
files: ['**/*.d.ts'],
rules: {
'no-var': 'off',
},
},
{
// ❗ALWAYS LAST
// Rules for codeblocks inside Markdown/MDX
Expand Down
4 changes: 2 additions & 2 deletions examples/graphiql-create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"dependencies": {
"graphiql": "^3.4.0",
"graphql": "^16.9.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-scripts": "5.0.1"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/graphiql-parcel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"dependencies": {
"graphiql": "^2.2.0",
"graphql": "^16.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react": "^19.1.0",
"react-dom": "^19.1.0"
},
"devDependencies": {
"parcel": "^2.5.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/graphiql-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"graphiql": "^3.9.0",
"graphql": "^16.9.0",
"graphql-ws": "^5.5.5",
"react": "^18.2.0",
"react": "^19.1.0",
"regenerator-runtime": "^0.13.9"
},
"devDependencies": {
Expand All @@ -29,7 +29,7 @@
"cross-env": "^7.0.2",
"css-loader": "^6.7.3",
"html-webpack-plugin": "^5.5.0",
"react-dom": "^18.2.0",
"react-dom": "^19.1.0",
"style-loader": "^3.3.1",
"webpack": "5.94.0",
"webpack-cli": "^5.0.1",
Expand Down
6 changes: 3 additions & 3 deletions examples/monaco-graphql-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"monaco-graphql": "^1.6.1",
"next": "13.4.7",
"prettier": "3.3.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react": "^19.1.0",
"react-dom": "^19.1.0"
},
"devDependencies": {
"@types/node": "^16.18.4",
"@types/react": "18.2.14",
"@types/react": "^19.1.2",
"next-global-css": "1.3.1",
"typescript": "^4.6.3"
}
Expand Down
6 changes: 3 additions & 3 deletions examples/monaco-graphql-react-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"monaco-editor": "^0.39.0",
"monaco-graphql": "^1.6.1",
"prettier": "3.3.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react": "^19.1.0",
"react-dom": "^19.1.0"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.3.1",
"@vitejs/plugin-react": "^4.4.1",
"vite": "^5.4.18",
"vite-plugin-monaco-editor": "^1.1.0"
},
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
"resolutions": {
"@babel/traverse": "^7.23.2",
"vscode-languageserver-types": "3.17.3",
"markdown-it": "14.1.0"
"markdown-it": "14.1.0",
"react": "18.3.1",
"react-dom": "18.3.1"
}
}
10 changes: 5 additions & 5 deletions packages/graphiql-plugin-code-exporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
"peerDependencies": {
"@graphiql/react": "^0.29.0",
"graphql": "^15.5.0 || ^16.0.0 || ^17.0.0",
"react": "^16.8.0 || ^17 || ^18",
"react-dom": "^16.8.0 || ^17 || ^18"
"react": "^18 || ^19",
"react-dom": "^18 || ^19"
},
"devDependencies": {
"@graphiql/react": "^0.29.0",
"@vitejs/plugin-react": "^4.3.1",
"@vitejs/plugin-react": "^4.4.1",
"graphql": "^16.9.0",
"postcss-nesting": "^10.1.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"typescript": "^4.6.3",
"vite": "^5.4.18"
}
Expand Down
10 changes: 5 additions & 5 deletions packages/graphiql-plugin-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
"peerDependencies": {
"@graphiql/react": "^0.29.0",
"graphql": "^15.5.0 || ^16.0.0 || ^17.0.0",
"react": "^16.8.0 || ^17 || ^18",
"react-dom": "^16.8.0 || ^17 || ^18"
"react": "^18 || ^19",
"react-dom": "^18 || ^19"
},
"devDependencies": {
"@graphiql/react": "^0.29.0",
"@vitejs/plugin-react": "^4.3.1",
"@vitejs/plugin-react": "^4.4.1",
"graphql": "^16.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"typescript": "^4.6.3",
"vite": "^5.4.18",
"vite-plugin-svgr": "^4.2.0"
Expand Down
52 changes: 26 additions & 26 deletions packages/graphiql-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "@graphiql/react",
"version": "0.29.0",
"sideEffects": [
"*.css"
],
"repository": {
"type": "git",
"url": "https://github.com/graphql/graphiql",
Expand All @@ -12,19 +15,17 @@
},
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"exports": {
"./package.json": "./package.json",
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./types/index.d.ts"
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./font/roboto.css": "./font/roboto.css",
"./font/fira-code.css": "./font/fira-code.css",
"./dist/style.css": "./dist/style.css"
},
"types": "types/index.d.ts",
"types": "dist/index.d.ts",
"keywords": [
"react",
"graphql",
Expand All @@ -33,56 +34,55 @@
],
"files": [
"dist",
"font",
"src",
"types"
"font"
],
"scripts": {
"prebuild": "rimraf dist types",
"dev": "concurrently 'tsc --emitDeclarationOnly --watch' 'vite build --watch'",
"build": "tsc --emitDeclarationOnly && vite build",
"test": "vitest"
"dev": "vite build --watch",
"build": "vite build",
"test": "vitest",
"types:check": "tsc --noEmit"
},
"peerDependencies": {
"graphql": "^15.5.0 || ^16.0.0 || ^17.0.0",
"react": "^16.8.0 || ^17 || ^18",
"react-dom": "^16.8.0 || ^17 || ^18"
"react": "^18 || ^19",
"react-dom": "^18 || ^19"
},
"dependencies": {
"react-compiler-runtime": "19.1.0-rc.1",
"@graphiql/toolkit": "^0.11.2",
"@headlessui/react": "^1.7.15",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@radix-ui/react-tooltip": "^1.0.6",
"@radix-ui/react-visually-hidden": "^1.0.3",
"@headlessui/react": "^2.2",
"@radix-ui/react-dialog": "^1.1",
"@radix-ui/react-dropdown-menu": "^2.1",
"@radix-ui/react-tooltip": "^1.2",
"@radix-ui/react-visually-hidden": "^1.2",
"@types/codemirror": "^5.60.8",
"clsx": "^1.2.1",
"codemirror": "^5.65.3",
"codemirror-graphql": "^2.2.1",
"copy-to-clipboard": "^3.2.0",
"framer-motion": "^6.5.1",
"framer-motion": "^12",
"get-value": "^3.0.1",
"graphql-language-service": "^5.3.1",
"markdown-it": "^14.1.0",
"set-value": "^4.1.0"
},
"devDependencies": {
"babel-plugin-react-compiler": "19.1.0-rc.1",
"@types/react-dom": "^18.3.1",
"@types/react-dom": "^19.1.2",
"@babel/helper-string-parser": "^7.19.4",
"@testing-library/dom": "^10.4.0",
"@testing-library/react": "^16.1.0",
"@types/markdown-it": "^14.1.2",
"@types/get-value": "^3.0.5",
"@types/set-value": "^4.0.1",
"@vitejs/plugin-react": "^4.3.1",
"@vitejs/plugin-react": "^4.4.1",
"graphql": "^16.9.0",
"postcss-nesting": "^10.1.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"typescript": "^4.6.3",
"vite": "^5.4.18",
"vite-plugin-svgr": "^4.2.0"
"vite": "^6.3.3",
"vite-plugin-svgr": "^4.2.0",
"vite-plugin-dts": "^4.5.3"
}
}
2 changes: 1 addition & 1 deletion packages/graphiql-react/src/editor/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function importCodeMirror(
) {
const CodeMirror = await import('codemirror').then(c =>
// Depending on bundler and settings the dynamic import either returns a
// function (e.g. parcel) or an object containing a `default` property
// function (e.g., parcel) or an object containing a `default` property
typeof c === 'function' ? c : c.default,
);
await Promise.all(
Expand Down
4 changes: 2 additions & 2 deletions packages/graphiql-react/src/editor/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export type EditorContextProviderProps = {
* - Adding a tab
* - Switching to a different tab
* - Closing a tab
* @param tabState The tabs state after it has been updated.
* @param tabState The tab state after it has been updated.
*/
onTabChange?(tabState: TabsState): void;
/**
Expand Down Expand Up @@ -336,7 +336,7 @@ export function EditorContextProvider(props: EditorContextProviderProps) {
storage?.set(PERSIST_HEADERS_STORAGE_KEY, persist.toString());
};

const lastShouldPersistHeadersProp = useRef<boolean | undefined>();
const lastShouldPersistHeadersProp = useRef<boolean | undefined>(undefined);
useEffect(() => {
const propValue = Boolean(props.shouldPersistHeaders);
if (lastShouldPersistHeadersProp?.current !== propValue) {
Expand Down
10 changes: 5 additions & 5 deletions packages/graphiql-react/src/editor/query-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
GraphQLDocumentMode,
OperationFacts,
} from 'graphql-language-service';
import { MutableRefObject, useEffect, useRef } from 'react';
import { RefObject, useEffect, useRef } from 'react';

import { useExecutionContext } from '../execution';
import { useExplorerContext } from '../explorer';
Expand Down Expand Up @@ -149,7 +149,7 @@ export function useQueryEditor(
const merge = useMergeQuery({ caller: caller || _useQueryEditor });
const prettify = usePrettifyEditors({ caller: caller || _useQueryEditor });
const ref = useRef<HTMLDivElement>(null);
const codeMirrorRef = useRef<CodeMirrorType>();
const codeMirrorRef = useRef<CodeMirrorType>(undefined);

const onClickReferenceRef = useRef<
NonNullable<UseQueryEditorArgs['onClickReference']>
Expand Down Expand Up @@ -474,7 +474,7 @@ export function useQueryEditor(
function useSynchronizeSchema(
editor: CodeMirrorEditor | null,
schema: GraphQLSchema | null,
codeMirrorRef: MutableRefObject<CodeMirrorType | undefined>,
codeMirrorRef: RefObject<CodeMirrorType | undefined>,
) {
useEffect(() => {
if (!editor) {
Expand All @@ -493,7 +493,7 @@ function useSynchronizeSchema(
function useSynchronizeValidationRules(
editor: CodeMirrorEditor | null,
validationRules: ValidationRule[] | null,
codeMirrorRef: MutableRefObject<CodeMirrorType | undefined>,
codeMirrorRef: RefObject<CodeMirrorType | undefined>,
) {
useEffect(() => {
if (!editor) {
Expand All @@ -512,7 +512,7 @@ function useSynchronizeValidationRules(
function useSynchronizeExternalFragments(
editor: CodeMirrorEditor | null,
externalFragments: Map<string, FragmentDefinitionNode>,
codeMirrorRef: MutableRefObject<CodeMirrorType | undefined>,
codeMirrorRef: RefObject<CodeMirrorType | undefined>,
) {
const externalFragmentList = [...externalFragments.values()]; // eslint-disable-line react-hooks/exhaustive-deps -- false positive, variable is optimized by react-compiler, no need to wrap with useMemo

Expand Down
Loading
Loading