davazp / graphql-mode

An Emacs mode for GraphQL
GNU General Public License v3.0
162 stars 31 forks source link

Simplify .graphqlconfig somehow #56

Open j3pic opened 1 year ago

j3pic commented 1 year ago

I find it highly irritating that GraphQL URLs must be written into the poorly-documented structure of .graphqlconfig, and to make it worse, this file must appear in the same directory that the GraphQL-Mode buffer considers itself to be in (I only use this buffer to write queries I mean to submit to the server). Since the only two things I'm interested in configuring are the URL and the headers, it would be nice if these could be set through Emacs Lisp variables. Then I wouldn't have to have guessed the fact that you don't actually have to supply a .graphql schema file, even though this option appears at a lower depth in the structure and is not marked as an "extension".

The very worst part about it is that if you make a mistake in .graphqlconfig, there's no obvious way to fix it because GraphQL-Mode caches the file. I made a typo in the URL, and GraphQL-Mode just kept using the typo-containing version of the URL even after I fixed it in .graphqlconfig.

davazp commented 1 year ago

Hi @j3pic , thanks for sharing your impressions with it. I'm not very actively using this package now, but hopefully someone is willing to open a pull request to solve those issues.

In the mean time, you can try the even buffer-local variable as described in the even more poorly documented issue here: https://github.com/davazp/graphql-mode/issues/21#issuecomment-449578289

Some ideas for the issues you found:

...the poorly-documented structure of .graphqlconfig

It'd be nice to add some examples to the README.md

this file must appear in the same directory that the GraphQL-Mode buffer considers itself to be in

We could check what other editors do. Looking for a config in all the ancestor directories is an easy change, and if it doesn't find any it could ask interactively and save the variable.

The very worst part about it is that if you make a mistake in .graphqlconfig, there's no obvious way to fix it because GraphQL-Mode caches the file.

Yeah that sounds annoying. I guess we could change that so it is parsed for every query. Only if the buffer-local variables aren't defined.