graphql-playground icon indicating copy to clipboard operation
graphql-playground copied to clipboard

It's not possible to Save to File

Open theholiday opened this issue 8 years ago • 5 comments

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.

theholiday avatar Nov 26 '18 10:11 theholiday

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?

  1. Open application
  2. 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)

twslade avatar Feb 14 '19 16:02 twslade

Experiencing the same issue -- would be nice to be able to save all open files in the workspace as well.

steve-a-jones avatar Mar 13 '19 13:03 steve-a-jones

Looks like dup of #749

jboehle avatar Mar 26 '19 15:03 jboehle

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?

calwayne avatar Jul 31 '19 02:07 calwayne

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.

prantlf avatar Aug 17 '19 10:08 prantlf