JetBrains / js-graphql-intellij-plugin

GraphQL language support for WebStorm, IntelliJ IDEA and other IDEs based on the IntelliJ Platform.
https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/
MIT License
879 stars 97 forks source link

Persist the variables of GraphQL operations #83

Open andresrinivasan opened 7 years ago

andresrinivasan commented 7 years ago

I added variables by toggling the variables window and then adding them. When I close the variables window the variables are lost.

Is there a way to persist this setting? Or perhaps there is an external .json file I need to create to hold the variables?

jimkyndemeyer commented 7 years ago

This isn't supported at the moment. A PR would be great :)

Starkom commented 5 years ago

Moreover, when I open variable window and add there a very big variable (several screens), variable window overlaps main editor window. There is a workaround with creadcrumb right-click -> "jump to source" and open '/GraphQL.variables.json' in new editor window. So you can edit variables in normal way. But it will be gone anyway after some actions.

Vadorequest commented 5 years ago

I'd also like a variable file, I'm importing existing content so I'd need it to store the values, typing them by hand isn't reliable in my case, but a good option for scripting

jimkyndemeyer commented 5 years ago

The upcoming 2.0.1 release no longer clears the variables editor when closing it.

There are still some open questions:

Vadorequest commented 5 years ago

The way I see it for my use case would be as follow:

This way, it would be very customisable, the template could be generated dynamically or manually, same goes for the implementation. It could be tracked by git, and could be used to manage utility scripts such as importing predefined content.

I would typically use this for migrating data, basically write the templates by hand and the iterate over existing data to generate the "implementation" files and be able to run them again by hand (several at once? nice-to-have) I would also use it to write my own utility suite of scripts to perform redundant actions much faster.

denys-meloshyn commented 4 years ago

I would also be super happy to store my editor variables so I can test quickly my queries after I rest the IDE

denys-meloshyn commented 4 years ago

As a possible solution, maybe it is possible to store variables as json file and associate them to query?

Granitosaurus commented 4 years ago

As a possible solution, maybe it is possible to store variables as json file and associate them to query?

I was about to open up an issue with this suggestion. It would be nice to keep variables in a file for posterity reasoning. Right now we're keeping in variables in separate json file and a contributor has to manually move them to the variable window to test the queries :|

as @Starkom pointed out the variables are already in /GraphQL.variables.json file? I can't find it anywhere and creating one in root directory (next to config) doesn't make a difference.

olof-nord commented 1 year ago

Love this extension. Really super powerful, I use it a lot. Thanks for doing this!

Seeing that the readme for v4 mentions variables, I was digging deeper into this and from what I can tell now variables are supported by a project root 'graphql.variables.json' file? When selecting the yellow V from the GraphQL toolbar nothing happens, but reading the source code I understood this is the expected file name (?)

Defining key-value pairs in this file however does not have any effect - does it need to be included or activated somehow?

WebStorm 2023.1, Build #WS-231.8109.174. Runtime version: 17.0.6+10-b829.5 aarch64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS ventura 13.1

vepanimas commented 1 year ago

@olof-nord Oh, looks like we have an issue with 2023.1 😮. It's expected to work like that, and it works in 2022.3, but not in 2023.1. I'll check it.

https://user-images.githubusercontent.com/10243762/233806816-82418f3e-42fa-4812-9e8e-4402353582c5.mp4

olof-nord commented 1 year ago

Just upgraded to 4.0.1 and the variables editor is working. Thank you!

yhc44 commented 3 months ago

Hello, is there any chance variable persistence will be implemented in the future?

It is really frustrating to enter variables again and again from time to time.