graphql / graphiql

GraphiQL & the GraphQL LSP Reference Ecosystem for building browser & IDE tools.
MIT License
16.02k stars 1.72k forks source link

[graphiql] Unknown operation named 'xyz' #3632

Open justinsumida opened 3 months ago

justinsumida commented 3 months ago

Is there an existing issue for this?

Current Behavior

Using the latest of GraphiQL from CDN, having multiple queries works on initial page load. Refreshing the browser ignores other queries/mutations and runs the first query. I am unable to select any other query/mutation on the play button:

image

As you can see, I have two different queries. When pressing the play button (or Control + Enter) I get the error. The query 'search' was originally the first query on the editor, but I removed it.

Expected Behavior

Whatever queries are on the editor should appear as options on the play button.

Steps To Reproduce

  1. Using latest GraphiQL version, create multiple queries. Refresh the page and attempt to run any other query other than the first one on the page.

Environment

Anything else?

No response

justinsumida commented 3 months ago

This can also be reproduced on https://graphql.github.io/swapi-graphql

How I set it up: Create two queries something like this:

image

Refresh the page... I am unable to run "anotherOne"...all I can do is run "allFilms"

image

Better yet... if I remove "allFilms" I see this...

image
justinsumida commented 3 months ago

Taking a look at what GraphQL receives:

image image

The operation name does not match what is happening. So I see a couple of problems:

  1. The editor sometimes "forgets" or loses that there are multiple operations in the tab
  2. The operation name does not change when attempting to run an operation