From 24e6897b1e47996243f4a9e99e3dd1b7cf6add27 Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Fri, 30 Jan 2026 16:21:41 -0700 Subject: [PATCH 01/14] fix prettify button to turn red on error --- .../graphiql-react/src/components/toolbar-button/index.tsx | 5 +++-- packages/graphiql-react/src/stores/editor.ts | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/graphiql-react/src/components/toolbar-button/index.tsx b/packages/graphiql-react/src/components/toolbar-button/index.tsx index 0238d256627..0c3816e962a 100644 --- a/packages/graphiql-react/src/components/toolbar-button/index.tsx +++ b/packages/graphiql-react/src/components/toolbar-button/index.tsx @@ -11,16 +11,17 @@ import './index.css'; interface ToolbarButtonProps extends ComponentPropsWithoutRef<'button'> { label: string; + onClick: (args?: any) => (any | Promise); } export const ToolbarButton = forwardRef( ({ label, onClick, ...props }, ref) => { const [error, setError] = useState(null); - const handleClick: MouseEventHandler = event => { + const handleClick: MouseEventHandler = async event => { try { // Optional chaining inside try-catch isn't supported yet by react-compiler if (onClick) { - onClick(event); + await onClick(event); } setError(null); } catch (err) { diff --git a/packages/graphiql-react/src/stores/editor.ts b/packages/graphiql-react/src/stores/editor.ts index d553e1027ac..338e10d2c29 100644 --- a/packages/graphiql-react/src/stores/editor.ts +++ b/packages/graphiql-react/src/stores/editor.ts @@ -492,6 +492,7 @@ export const createEditorSlice: CreateEditorSlice = initial => (set, get) => { 'Parsing variables JSON failed, skip prettification.', error, ); + throw error; } } @@ -508,6 +509,7 @@ export const createEditorSlice: CreateEditorSlice = initial => (set, get) => { 'Parsing headers JSON failed, skip prettification.', error, ); + throw error; } } @@ -522,7 +524,8 @@ export const createEditorSlice: CreateEditorSlice = initial => (set, get) => { } } catch (error) { // eslint-disable-next-line no-console - console.warn('Parsing query failed, skip prettification.', error); + console.warn('THROW Parsing query failed, skip prettification.', error); + throw error; } }, mergeQuery() { From 68d7b46ed28dc1c76c39198852f27ffa25f0dd2c Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Fri, 30 Jan 2026 16:27:15 -0700 Subject: [PATCH 02/14] fix for prettier --- packages/graphiql-react/src/components/toolbar-button/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/graphiql-react/src/components/toolbar-button/index.tsx b/packages/graphiql-react/src/components/toolbar-button/index.tsx index 0c3816e962a..d7f50ac49c5 100644 --- a/packages/graphiql-react/src/components/toolbar-button/index.tsx +++ b/packages/graphiql-react/src/components/toolbar-button/index.tsx @@ -11,7 +11,7 @@ import './index.css'; interface ToolbarButtonProps extends ComponentPropsWithoutRef<'button'> { label: string; - onClick: (args?: any) => (any | Promise); + onClick: (args?: any) => any | Promise; } export const ToolbarButton = forwardRef( From 81755240acec72af3c0c5d00d368f68965ac92d3 Mon Sep 17 00:00:00 2001 From: lesleydreyer <38596053+lesleydreyer@users.noreply.github.com> Date: Fri, 30 Jan 2026 16:41:02 -0700 Subject: [PATCH 03/14] Fix onClick type to optional Made the onClick prop optional in ToolbarButtonProps. --- packages/graphiql-react/src/components/toolbar-button/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/graphiql-react/src/components/toolbar-button/index.tsx b/packages/graphiql-react/src/components/toolbar-button/index.tsx index d7f50ac49c5..8970a88fa2f 100644 --- a/packages/graphiql-react/src/components/toolbar-button/index.tsx +++ b/packages/graphiql-react/src/components/toolbar-button/index.tsx @@ -11,7 +11,7 @@ import './index.css'; interface ToolbarButtonProps extends ComponentPropsWithoutRef<'button'> { label: string; - onClick: (args?: any) => any | Promise; + onClick?: (args?: any) => any | Promise; } export const ToolbarButton = forwardRef( From 7c9c21e97b2dbb91387e65a87925c89e78a3a2e8 Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Thu, 12 Feb 2026 14:29:25 -0700 Subject: [PATCH 04/14] try fix test --- packages/graphiql/cypress/support/commands.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/graphiql/cypress/support/commands.ts b/packages/graphiql/cypress/support/commands.ts index 7e7f6c2f51f..7058b8fcc73 100644 --- a/packages/graphiql/cypress/support/commands.ts +++ b/packages/graphiql/cypress/support/commands.ts @@ -60,7 +60,7 @@ Cypress.Commands.add('clickExecuteQuery', () => { }); Cypress.Commands.add('clickPrettify', () => { - cy.get('[aria-label="Prettify query (Shift-Ctrl-P)"]').click(); + cy.get('[aria-label="Prettify query (Shift-Ctrl-P)"]').click().then((res) => res); }); Cypress.Commands.add('visitWithOp', ({ query, variables, variablesString }) => { From 8ecbebf6429172ad50d4f9d21f20c6c434879a55 Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Thu, 12 Feb 2026 14:39:39 -0700 Subject: [PATCH 05/14] try fix test --- packages/graphiql/cypress/support/commands.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/graphiql/cypress/support/commands.ts b/packages/graphiql/cypress/support/commands.ts index 7058b8fcc73..65b0e0d9a72 100644 --- a/packages/graphiql/cypress/support/commands.ts +++ b/packages/graphiql/cypress/support/commands.ts @@ -60,7 +60,8 @@ Cypress.Commands.add('clickExecuteQuery', () => { }); Cypress.Commands.add('clickPrettify', () => { - cy.get('[aria-label="Prettify query (Shift-Ctrl-P)"]').click().then((res) => res); + cy.get('[aria-label="Prettify query (Shift-Ctrl-P)"]').click(); + cy.wait(500); }); Cypress.Commands.add('visitWithOp', ({ query, variables, variablesString }) => { From a20ddd87d69d85f4ae30607c9b92aaf66dcf76b2 Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Thu, 12 Feb 2026 14:54:45 -0700 Subject: [PATCH 06/14] try fix test --- packages/graphiql/cypress/e2e/prettify.cy.ts | 20 +++++++++---------- packages/graphiql/cypress/support/commands.ts | 3 +-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/graphiql/cypress/e2e/prettify.cy.ts b/packages/graphiql/cypress/e2e/prettify.cy.ts index 9cfadd63167..9d68f63c197 100644 --- a/packages/graphiql/cypress/e2e/prettify.cy.ts +++ b/packages/graphiql/cypress/e2e/prettify.cy.ts @@ -26,18 +26,18 @@ const brokenQuery = 'longDescriptionType {id}}'; const brokenVariables = '"a": 1}'; describeOrSkip('GraphiQL Prettify', () => { - it('should work while click on prettify button', () => { + it('should work while click on prettify button', async () => { const rawQuery = '{ test\n\nid }'; const resultQuery = '{ test id }'; cy.visit(`?query=${rawQuery}&onPrettifyQuery=true`); - cy.clickPrettify(); + await cy.clickPrettify(); cy.assertHasValues({ query: resultQuery }); }); - it('Regular prettification', () => { + it('Regular prettification', async () => { cy.visitWithOp({ query: uglyQuery, variablesString: uglyVariables }); - cy.clickPrettify(); + await cy.clickPrettify(); cy.assertHasValues({ query: prettifiedQuery, @@ -45,13 +45,13 @@ describeOrSkip('GraphiQL Prettify', () => { }); }); - it('Noop prettification', () => { + it('Noop prettification', async () => { cy.visitWithOp({ query: prettifiedQuery, variablesString: prettifiedVariables, }); - cy.clickPrettify(); + await cy.clickPrettify(); cy.assertHasValues({ query: prettifiedQuery, @@ -59,10 +59,10 @@ describeOrSkip('GraphiQL Prettify', () => { }); }); - it('No crash on bad query', () => { + it('No crash on bad query', async () => { cy.visitWithOp({ query: brokenQuery, variablesString: uglyVariables }); - cy.clickPrettify(); + await cy.clickPrettify(); cy.assertHasValues({ query: brokenQuery, @@ -70,10 +70,10 @@ describeOrSkip('GraphiQL Prettify', () => { }); }); - it('No crash on bad variablesString', () => { + it('No crash on bad variablesString', async () => { cy.visitWithOp({ query: uglyQuery, variablesString: brokenVariables }); - cy.clickPrettify(); + await cy.clickPrettify(); cy.assertHasValues({ query: prettifiedQuery, diff --git a/packages/graphiql/cypress/support/commands.ts b/packages/graphiql/cypress/support/commands.ts index 65b0e0d9a72..e2c9b57644f 100644 --- a/packages/graphiql/cypress/support/commands.ts +++ b/packages/graphiql/cypress/support/commands.ts @@ -34,7 +34,7 @@ declare namespace Cypress { visitWithOp(op: Op): Chainable; - clickPrettify(): Chainable; + clickPrettify(): Promise; assertHasValues(op: Op): Chainable; @@ -61,7 +61,6 @@ Cypress.Commands.add('clickExecuteQuery', () => { Cypress.Commands.add('clickPrettify', () => { cy.get('[aria-label="Prettify query (Shift-Ctrl-P)"]').click(); - cy.wait(500); }); Cypress.Commands.add('visitWithOp', ({ query, variables, variablesString }) => { From 12dacf83e48a1c3b934813c8f57b9c4d455cbd28 Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Thu, 12 Feb 2026 15:25:07 -0700 Subject: [PATCH 07/14] try wrap --- packages/graphiql/cypress/e2e/prettify.cy.ts | 21 ++++++++++--------- packages/graphiql/cypress/support/commands.ts | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/graphiql/cypress/e2e/prettify.cy.ts b/packages/graphiql/cypress/e2e/prettify.cy.ts index 9d68f63c197..123cca727dc 100644 --- a/packages/graphiql/cypress/e2e/prettify.cy.ts +++ b/packages/graphiql/cypress/e2e/prettify.cy.ts @@ -26,18 +26,18 @@ const brokenQuery = 'longDescriptionType {id}}'; const brokenVariables = '"a": 1}'; describeOrSkip('GraphiQL Prettify', () => { - it('should work while click on prettify button', async () => { + it('should work while click on prettify button', () => { const rawQuery = '{ test\n\nid }'; const resultQuery = '{ test id }'; cy.visit(`?query=${rawQuery}&onPrettifyQuery=true`); - await cy.clickPrettify(); + cy.clickPrettify(); cy.assertHasValues({ query: resultQuery }); }); - it('Regular prettification', async () => { + it('Regular prettification', () => { cy.visitWithOp({ query: uglyQuery, variablesString: uglyVariables }); - await cy.clickPrettify(); + cy.clickPrettify(); cy.assertHasValues({ query: prettifiedQuery, @@ -45,13 +45,13 @@ describeOrSkip('GraphiQL Prettify', () => { }); }); - it('Noop prettification', async () => { + it('Noop prettification', () => { cy.visitWithOp({ query: prettifiedQuery, variablesString: prettifiedVariables, }); - await cy.clickPrettify(); + cy.clickPrettify(); cy.assertHasValues({ query: prettifiedQuery, @@ -59,10 +59,10 @@ describeOrSkip('GraphiQL Prettify', () => { }); }); - it('No crash on bad query', async () => { + it('No crash on bad query', () => { cy.visitWithOp({ query: brokenQuery, variablesString: uglyVariables }); - await cy.clickPrettify(); + cy.clickPrettify(); cy.assertHasValues({ query: brokenQuery, @@ -70,10 +70,11 @@ describeOrSkip('GraphiQL Prettify', () => { }); }); - it('No crash on bad variablesString', async () => { + it('No crash on bad variablesString', () => { cy.visitWithOp({ query: uglyQuery, variablesString: brokenVariables }); - await cy.clickPrettify(); + cy.wrap + cy.clickPrettify(); cy.assertHasValues({ query: prettifiedQuery, diff --git a/packages/graphiql/cypress/support/commands.ts b/packages/graphiql/cypress/support/commands.ts index e2c9b57644f..d0c531c5c7e 100644 --- a/packages/graphiql/cypress/support/commands.ts +++ b/packages/graphiql/cypress/support/commands.ts @@ -34,7 +34,7 @@ declare namespace Cypress { visitWithOp(op: Op): Chainable; - clickPrettify(): Promise; + clickPrettify(): Chainable; assertHasValues(op: Op): Chainable; @@ -60,7 +60,7 @@ Cypress.Commands.add('clickExecuteQuery', () => { }); Cypress.Commands.add('clickPrettify', () => { - cy.get('[aria-label="Prettify query (Shift-Ctrl-P)"]').click(); + cy.wrap(cy.get('[aria-label="Prettify query (Shift-Ctrl-P)"]').click({ })); }); Cypress.Commands.add('visitWithOp', ({ query, variables, variablesString }) => { From 5af8e427a4be2803a93e96c4ac499db3dff6c575 Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Thu, 12 Feb 2026 15:43:04 -0700 Subject: [PATCH 08/14] try fix test --- packages/graphiql/cypress/e2e/prettify.cy.ts | 1 - packages/graphiql/cypress/support/commands.ts | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/graphiql/cypress/e2e/prettify.cy.ts b/packages/graphiql/cypress/e2e/prettify.cy.ts index 123cca727dc..9cfadd63167 100644 --- a/packages/graphiql/cypress/e2e/prettify.cy.ts +++ b/packages/graphiql/cypress/e2e/prettify.cy.ts @@ -73,7 +73,6 @@ describeOrSkip('GraphiQL Prettify', () => { it('No crash on bad variablesString', () => { cy.visitWithOp({ query: uglyQuery, variablesString: brokenVariables }); - cy.wrap cy.clickPrettify(); cy.assertHasValues({ diff --git a/packages/graphiql/cypress/support/commands.ts b/packages/graphiql/cypress/support/commands.ts index d0c531c5c7e..6b7ce78810a 100644 --- a/packages/graphiql/cypress/support/commands.ts +++ b/packages/graphiql/cypress/support/commands.ts @@ -60,7 +60,8 @@ Cypress.Commands.add('clickExecuteQuery', () => { }); Cypress.Commands.add('clickPrettify', () => { - cy.wrap(cy.get('[aria-label="Prettify query (Shift-Ctrl-P)"]').click({ })); + const promise = cy.get('[aria-label="Prettify query (Shift-Ctrl-P)"]').click() + cy.wrap(promise); }); Cypress.Commands.add('visitWithOp', ({ query, variables, variablesString }) => { From 4ca8a935e5a17146293e9936a08a6e7623a0dba3 Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Thu, 12 Feb 2026 15:51:33 -0700 Subject: [PATCH 09/14] try fix test --- packages/graphiql/cypress/e2e/prettify.cy.ts | 47 ++++++++++--------- packages/graphiql/cypress/support/commands.ts | 3 +- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/packages/graphiql/cypress/e2e/prettify.cy.ts b/packages/graphiql/cypress/e2e/prettify.cy.ts index 9cfadd63167..6a880c47319 100644 --- a/packages/graphiql/cypress/e2e/prettify.cy.ts +++ b/packages/graphiql/cypress/e2e/prettify.cy.ts @@ -29,19 +29,22 @@ describeOrSkip('GraphiQL Prettify', () => { it('should work while click on prettify button', () => { const rawQuery = '{ test\n\nid }'; const resultQuery = '{ test id }'; + cy.visit(`?query=${rawQuery}&onPrettifyQuery=true`); - cy.clickPrettify(); - cy.assertHasValues({ query: resultQuery }); + + cy.clickPrettify().then(() => { + cy.assertHasValues({ query: resultQuery }); + }); }); it('Regular prettification', () => { cy.visitWithOp({ query: uglyQuery, variablesString: uglyVariables }); - cy.clickPrettify(); - - cy.assertHasValues({ - query: prettifiedQuery, - variablesString: prettifiedVariables, + cy.clickPrettify().then(() => { + cy.assertHasValues({ + query: prettifiedQuery, + variablesString: prettifiedVariables, + }); }); }); @@ -51,33 +54,33 @@ describeOrSkip('GraphiQL Prettify', () => { variablesString: prettifiedVariables, }); - cy.clickPrettify(); - - cy.assertHasValues({ - query: prettifiedQuery, - variablesString: prettifiedVariables, + cy.clickPrettify().then(() => { + cy.assertHasValues({ + query: prettifiedQuery, + variablesString: prettifiedVariables, + }); }); }); it('No crash on bad query', () => { cy.visitWithOp({ query: brokenQuery, variablesString: uglyVariables }); - cy.clickPrettify(); - - cy.assertHasValues({ - query: brokenQuery, - variablesString: prettifiedVariables, + cy.clickPrettify().then(() => { + cy.assertHasValues({ + query: brokenQuery, + variablesString: prettifiedVariables, + }); }); }); it('No crash on bad variablesString', () => { cy.visitWithOp({ query: uglyQuery, variablesString: brokenVariables }); - cy.clickPrettify(); - - cy.assertHasValues({ - query: prettifiedQuery, - variablesString: brokenVariables, + cy.clickPrettify().then(() => { + cy.assertHasValues({ + query: prettifiedQuery, + variablesString: brokenVariables, + }); }); }); }); diff --git a/packages/graphiql/cypress/support/commands.ts b/packages/graphiql/cypress/support/commands.ts index 6b7ce78810a..7e7f6c2f51f 100644 --- a/packages/graphiql/cypress/support/commands.ts +++ b/packages/graphiql/cypress/support/commands.ts @@ -60,8 +60,7 @@ Cypress.Commands.add('clickExecuteQuery', () => { }); Cypress.Commands.add('clickPrettify', () => { - const promise = cy.get('[aria-label="Prettify query (Shift-Ctrl-P)"]').click() - cy.wrap(promise); + cy.get('[aria-label="Prettify query (Shift-Ctrl-P)"]').click(); }); Cypress.Commands.add('visitWithOp', ({ query, variables, variablesString }) => { From 4e342ab128eb676ee7652d62693c9ebbd3020b60 Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Thu, 19 Feb 2026 12:32:01 -0700 Subject: [PATCH 10/14] fix test, collect errs at bottom --- packages/graphiql-react/src/stores/editor.ts | 17 +++++-- packages/graphiql/cypress/e2e/prettify.cy.ts | 47 +++++++++----------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/packages/graphiql-react/src/stores/editor.ts b/packages/graphiql-react/src/stores/editor.ts index 338e10d2c29..bebbca8fd18 100644 --- a/packages/graphiql-react/src/stores/editor.ts +++ b/packages/graphiql-react/src/stores/editor.ts @@ -478,6 +478,8 @@ export const createEditorSlice: CreateEditorSlice = initial => (set, get) => { async prettifyEditors() { const { queryEditor, headerEditor, variableEditor, onPrettifyQuery } = get(); + + const errors: any[] = []; if (variableEditor) { try { @@ -492,7 +494,7 @@ export const createEditorSlice: CreateEditorSlice = initial => (set, get) => { 'Parsing variables JSON failed, skip prettification.', error, ); - throw error; + errors.push(error); } } @@ -509,7 +511,7 @@ export const createEditorSlice: CreateEditorSlice = initial => (set, get) => { 'Parsing headers JSON failed, skip prettification.', error, ); - throw error; + errors.push(error); } } @@ -525,8 +527,17 @@ export const createEditorSlice: CreateEditorSlice = initial => (set, get) => { } catch (error) { // eslint-disable-next-line no-console console.warn('THROW Parsing query failed, skip prettification.', error); - throw error; + errors.push(error); } + + if (errors.length) { + if (errors.length > 1) { + const msg = errors.map((err) => err?.message || 'Error prettifying').join(', '); + throw new Error(msg); + } + throw errors[0]; + } + }, mergeQuery() { const { queryEditor, documentAST, schema } = get(); diff --git a/packages/graphiql/cypress/e2e/prettify.cy.ts b/packages/graphiql/cypress/e2e/prettify.cy.ts index 6a880c47319..9cfadd63167 100644 --- a/packages/graphiql/cypress/e2e/prettify.cy.ts +++ b/packages/graphiql/cypress/e2e/prettify.cy.ts @@ -29,22 +29,19 @@ describeOrSkip('GraphiQL Prettify', () => { it('should work while click on prettify button', () => { const rawQuery = '{ test\n\nid }'; const resultQuery = '{ test id }'; - cy.visit(`?query=${rawQuery}&onPrettifyQuery=true`); - - cy.clickPrettify().then(() => { - cy.assertHasValues({ query: resultQuery }); - }); + cy.clickPrettify(); + cy.assertHasValues({ query: resultQuery }); }); it('Regular prettification', () => { cy.visitWithOp({ query: uglyQuery, variablesString: uglyVariables }); - cy.clickPrettify().then(() => { - cy.assertHasValues({ - query: prettifiedQuery, - variablesString: prettifiedVariables, - }); + cy.clickPrettify(); + + cy.assertHasValues({ + query: prettifiedQuery, + variablesString: prettifiedVariables, }); }); @@ -54,33 +51,33 @@ describeOrSkip('GraphiQL Prettify', () => { variablesString: prettifiedVariables, }); - cy.clickPrettify().then(() => { - cy.assertHasValues({ - query: prettifiedQuery, - variablesString: prettifiedVariables, - }); + cy.clickPrettify(); + + cy.assertHasValues({ + query: prettifiedQuery, + variablesString: prettifiedVariables, }); }); it('No crash on bad query', () => { cy.visitWithOp({ query: brokenQuery, variablesString: uglyVariables }); - cy.clickPrettify().then(() => { - cy.assertHasValues({ - query: brokenQuery, - variablesString: prettifiedVariables, - }); + cy.clickPrettify(); + + cy.assertHasValues({ + query: brokenQuery, + variablesString: prettifiedVariables, }); }); it('No crash on bad variablesString', () => { cy.visitWithOp({ query: uglyQuery, variablesString: brokenVariables }); - cy.clickPrettify().then(() => { - cy.assertHasValues({ - query: prettifiedQuery, - variablesString: brokenVariables, - }); + cy.clickPrettify(); + + cy.assertHasValues({ + query: prettifiedQuery, + variablesString: brokenVariables, }); }); }); From c3fa5c65204003e7b045408b8e689ae35512046a Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Thu, 19 Feb 2026 12:35:11 -0700 Subject: [PATCH 11/14] fix prettify --- packages/graphiql-react/src/stores/editor.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/graphiql-react/src/stores/editor.ts b/packages/graphiql-react/src/stores/editor.ts index bebbca8fd18..f4095cb0825 100644 --- a/packages/graphiql-react/src/stores/editor.ts +++ b/packages/graphiql-react/src/stores/editor.ts @@ -478,7 +478,7 @@ export const createEditorSlice: CreateEditorSlice = initial => (set, get) => { async prettifyEditors() { const { queryEditor, headerEditor, variableEditor, onPrettifyQuery } = get(); - + const errors: any[] = []; if (variableEditor) { @@ -529,15 +529,16 @@ export const createEditorSlice: CreateEditorSlice = initial => (set, get) => { console.warn('THROW Parsing query failed, skip prettification.', error); errors.push(error); } - + if (errors.length) { if (errors.length > 1) { - const msg = errors.map((err) => err?.message || 'Error prettifying').join(', '); + const msg = errors + .map(err => err?.message || 'Error prettifying') + .join(', '); throw new Error(msg); } throw errors[0]; } - }, mergeQuery() { const { queryEditor, documentAST, schema } = get(); From aca24a1654a92a8dd3fc688a08a4da35c284c676 Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Thu, 19 Feb 2026 12:58:05 -0700 Subject: [PATCH 12/14] fix to work if no queryEditor --- packages/graphiql-react/src/stores/editor.ts | 26 +++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/graphiql-react/src/stores/editor.ts b/packages/graphiql-react/src/stores/editor.ts index f4095cb0825..bd66352cee0 100644 --- a/packages/graphiql-react/src/stores/editor.ts +++ b/packages/graphiql-react/src/stores/editor.ts @@ -515,19 +515,21 @@ export const createEditorSlice: CreateEditorSlice = initial => (set, get) => { } } - if (!queryEditor) { - return; - } - try { - const content = queryEditor.getValue(); - const formatted = await onPrettifyQuery(content); - if (formatted !== content) { - queryEditor.setValue(formatted); + if (queryEditor) { + try { + const content = queryEditor.getValue(); + const formatted = await onPrettifyQuery(content); + if (formatted !== content) { + queryEditor.setValue(formatted); + } + } catch (error) { + // eslint-disable-next-line no-console + console.warn( + 'THROW Parsing query failed, skip prettification.', + error, + ); + errors.push(error); } - } catch (error) { - // eslint-disable-next-line no-console - console.warn('THROW Parsing query failed, skip prettification.', error); - errors.push(error); } if (errors.length) { From 14f2dc762887776ac1fe94860df36879c6296dff Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Thu, 19 Feb 2026 13:05:34 -0700 Subject: [PATCH 13/14] cleanup --- packages/graphiql-react/src/stores/editor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/graphiql-react/src/stores/editor.ts b/packages/graphiql-react/src/stores/editor.ts index bd66352cee0..f06b17873de 100644 --- a/packages/graphiql-react/src/stores/editor.ts +++ b/packages/graphiql-react/src/stores/editor.ts @@ -525,7 +525,7 @@ export const createEditorSlice: CreateEditorSlice = initial => (set, get) => { } catch (error) { // eslint-disable-next-line no-console console.warn( - 'THROW Parsing query failed, skip prettification.', + 'Parsing query failed, skip prettification.', error, ); errors.push(error); From 9c566f535f9882d4c968afa3020f4e5f1ca38053 Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Thu, 19 Feb 2026 13:13:25 -0700 Subject: [PATCH 14/14] fix pretty --- packages/graphiql-react/src/stores/editor.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/graphiql-react/src/stores/editor.ts b/packages/graphiql-react/src/stores/editor.ts index f06b17873de..54fe2411f32 100644 --- a/packages/graphiql-react/src/stores/editor.ts +++ b/packages/graphiql-react/src/stores/editor.ts @@ -524,10 +524,7 @@ export const createEditorSlice: CreateEditorSlice = initial => (set, get) => { } } catch (error) { // eslint-disable-next-line no-console - console.warn( - 'Parsing query failed, skip prettification.', - error, - ); + console.warn('Parsing query failed, skip prettification.', error); errors.push(error); } }