GraphQL Operations Menu is not disabled and causes "operationName" to be empty
Expected Behavior
If there's no options, the Operations button should be disabled.
Actual Behavior
There´s an empty option in the menu, that if selected, it adds "operationName":"" to the query, which leads to the error "Unknown operation named \"\".",, and once selected, there's no way to remove the selection.

Reproduction Steps
- Update to version 2022.7.2
- Create a GraphQL request
- Select the empty option in the Operations Menu (note: some querys may have the option pre-selected, i haven't figured why)
Is there an existing issue for this?
- [x] I have searched the issue tracker for this problem.
Additional Information
i have updated to the 2022.7.2 version and noticed that some mutations where returning an error about an Unknown operation, so i noticed that the Operations menu had an empty option that i can not remove the selection. i asked some members of my team if they could send an screenshot of their version and the Operations button disabled. the latest version where this issue doesn't happen seems to be version 2022.7.0, here are the screenshots:

Insomnia Version
2022.7.2
What operating system are you using?
Windows
Operating System Version
Windows 11 Pro 22H2
Installation method
from insomnia.rest
Last Known Working Insomnia version
2022.7.0
Same here. On MacOs. Since this morning, after the upgrade to 2022.7.2, as soon as I change something in a request body, I get:
{
"errors": [
{
"message": "Unknown operation named \"\".",
"extensions": {
"category": "graphql"
}
}
]
}
Yes, just wanted to write the same: Bug also occurs on MacOS. But I'd like to add something else to it.
Strangely the ,"operationName":"" in the request is added only when editing the query somehow (it's enough to add an empty space or something, even in comment lines, doesn't matter). From then on the ,"operationName":"" is always added to the request.
When on the other hand importing backups of my collections in the data tab of the settings, then this is resetting that operation option or whatever happens there. In other words: My queries work again, until I again change a single character (which unfortunately happens a lot for me as a developer of a GraphQL API who's gotta test all his stuff 😅 ).
Echoing @dueddel, I've run edited and unedited queries against two GraphQL servers. Requests I created before installing v2022.7.2 can access both servers. In their timelines, I can see that Insomnia's payload includes only a query parameter:
POST /graphql HTTP/2
Host: tower.voxmedia.com
user-agent: insomnia/2022.7.2
content-type: application/json
accept: */*
content-length: 35
{"query":"query {\n\theartbeat\n}"}
HTTP/2 200
date: Sat, 14 Jan 2023 22:33:16 GMT
content-type: application/json; charset=utf-8
content-length: 28
vary: Origin
access-control-allow-origin: *
{
"data": {
"heartbeat": "OK"
}
}
If I edit the GraphQL body or create a new request, Insomnia sends an empty operationName. It gets a 400 back:
POST /graphql HTTP/2
Host: tower.voxmedia.com
user-agent: insomnia/2022.7.2
content-type: application/json
accept: */*
content-length: 56
{"query":"query {\n\theartbeat\n}\n","operationName":""}
HTTP/2 400
date: Sat, 14 Jan 2023 22:35:51 GMT
content-type: application/json; charset=utf-8
content-length: 103
vary: Origin
access-control-allow-origin: *
{
"errors": [
{
"message": "Unknown operation named \"\".",
"extensions": {
"code": "INTERNAL_SERVER_ERROR"
}
}
]
}
Restoring an earlier version of Insomnia will not fix requests with broken operationNames. Requests corrupted by this bug in v2022.7.2 will still have an empty “Operation” set in the GraphQL body in v2022.7.1. The field can’t be edited or removed. It carries over into duplicates as well. You’ll have to recreate them from scratch. Folks who run into this bug should immediately downgrade to v2022.7.1.
I'm having this problem on W11 also! As other people mentioned on this thread I can see that the problem relies on the operationName being an empty string key in the requestParams variable, as the image below:

When running from another API tester, I can see that the operationName key is not added to the requestParams variable, as show in the image below:

For now I will downgrade as suggested by @phyllisstein !
Hey folks, we have a consistent reproduction for this issue, we'll be posting out a fix ASAP. In the meantime as a workaround try to downgrade versions.
Downgrading didn't fix messed up requests for me. The workaround which worked was:
- Export to a json
- Edit the json to delete "operationName"
- Delete older collections
- Import edited jsons
Hi folks,
The root cause is that the code is passing an empty string to the operationName property, which is expected to throw an error according to this unit test case from graphql-js.
We will make a fix for this shortly. Thank you for being engaging with us!
Hey folks, the fix that @marckong mentioned aboved is available on latest patch release 2022.7.4
I can confirm it's working correctly-(ish).
The old requests still have the same issue:

But if i delete the requests and re-create them, they are now working! We have a quite large project where over 200 requests had this issue, i just removed the project and git cloned it again. Howerver, it still shows the empty options on the Operations Menu, but this time it doesn't interfere with the request.

Hope this gets fixed in the future and thank you for the rapid response to this issue.
Updated to 2022.7.5 and running into the same issue again.
No stable way to reproduce, though: appears and disappears randomly after toying with the operation name.
After adding the name, sometimes get something like this:

Seems like the operation name is still passed incorrectly somehow.

Update: exported the request as cURL, can see that, while the data is correct ("query FilteredApps"), the operationName is indeed passed as "FilteredAp".