It's not possible to Save to File
This issue pertains to the following package(s):
- [x] GraphQL Playground
What OS and OS version are you experiencing the issue(s) on?
Ubuntu LTS 18.04 (also not working on macOS 10.14.1)
What version of graphql-playground(-electron/-middleware) are you experiencing the issue(s) on?
1.8.2. (also not working on 1.8.3.)
What is the expected behaviour?
It should be possible to save to file.
What is the actual behaviour?
It's not possible to save to file.
What steps may we take to reproduce the behaviour?
Create a request and try to save it to file. After clicking Save to File nothing happens.
Please provide a gif or image of the issue for a quicker response/fix.
Not much to add, just try to save and nothing will happen.
Getting the same error above with the same OS.
What version of graphql-playground(-electron/-middleware) are you experiencing the issue(s) on?
1.8.9
What is the expected behaviour?
It should be possible to save to file.
What is the actual behaviour?
It's not possible to save to file both using the keyboard shortcut and using the menu
What steps may we take to reproduce the behaviour?
- Open application
- Type Ctrl+S or Click Workspace -> Save File
Strack trace
Uncaught (in promise) TypeError: path must be a string or Buffer
at Object.fs.openSync (fs.js:646:18)
at Object.module.(anonymous function) [as openSync] (ELECTRON_ASAR.js:166:20)
at Object.fs.writeFileSync (fs.js:1303:33)
at Object.App._this.saveConfig [as onSaveConfig] (file:///opt/GraphQL%20Playground/resources/app.asar/lib/dist/app.e1a8da8df9b6a2322b5c.js:85770:16)
at Object.PlaygroundWrapper._this.handleSaveConfig [as onSaveConfig] (file:///opt/GraphQL%20Playground/resources/app.asar/lib/dist/app.e1a8da8df9b6a2322b5c.js:65684:29)
at Playground._this.handleSaveConfig (file:///opt/GraphQL%20Playground/resources/app.asar/lib/dist/app.e1a8da8df9b6a2322b5c.js:94174:25)
at file:///opt/GraphQL%20Playground/resources/app.asar/lib/dist/app.e1a8da8df9b6a2322b5c.js:85932:34
at new Promise (<anonymous>)
at new F (file:///opt/GraphQL%20Playground/resources/app.asar/lib/dist/app.e1a8da8df9b6a2322b5c.js:37749:28)
at App.getSaveFileName (file:///opt/GraphQL%20Playground/resources/app.asar/lib/dist/app.e1a8da8df9b6a2322b5c.js:85919:16)
at EventEmitter.App._this.readFileMessage (file:///opt/GraphQL%20Playground/resources/app.asar/lib/dist/app.e1a8da8df9b6a2322b5c.js:85760:27)
at emitTwo (events.js:126:13)
at EventEmitter.emit (events.js:214:7)
Experiencing the same issue -- would be nice to be able to save all open files in the workspace as well.
Looks like dup of #749
The function on UI is there but couldn't Save File in Workspace. What is the purpose of designing the UI rather than not saving any file?
If you do not open a query from a file, you won't be able to save it. There is no functionality "Save Query As" now.
This is related to #749, but not exactly the same, because this issue is about the graphql query and that one about the workspace configuration file file.
If you trigger saving and the current tab was not opened from a file, the workspace configuration will be saved instead. The error on the console is caused by a bug in saveConfig. Instead of checking if the workspace was opened from a file and either showing an error or choosing a name, it just uses the undefined configPath value to call writeFileSync. Obviously, the writeFileSync retaliates:
// v1.8.10/packages/graphql-playground-electron/src/renderer/components/App.tsx, line 490
fs.writeFileSync(_this.state.configPath, configString);
The code should be more robust in supporting the scenario that you start the playground with an endpoint only, not by opening a workspace file. Tabs with queries are never opened from graphql files in this case. "Save As" for a graphql query tab would be nice.