davazp/graphql-mode

Could I define graphql url in .graphql text file?

Closed this issue ยท 7 comments

Very nice package, on question is that could I define graphql url in .graphql text file,
say just add a line like # graphql_url = "http://127.0.0.1:graphql" directly in the beginning of current file or buffer?

Thanks!

You can use file variables to do that. For example, write:

# Local Variables:
# graphql-url: "test"
# End:

at the bottom of the file. Emacs will ask you if you want to set that variable for that file, warning that it could be unsafe to do so. If you approve it, it will set it.

@davazp Thanks!

# Local Variables:
# graphql-url: "http://127.0.0.1:3000/graphql"
# End:

I've added these above lines at the buttom of my .graphql file, but when I type C-c C-c, emacs shows an error message Wrong type argument: stringp, nil

You have to revisit the file for the variable to take effect. Try killing the buffer and reopening the file.

Yes, I've closed the file and re-opened it. It asked y, n, ! and I anwserd y.
It does not ask me to set graphql-url any more, but just raise the error message.

Ok, my mistake. There was an issue in the command. I have fixed it now. ๐Ÿ‘ thanks for reporting it.

It works now, thanks! ๐Ÿฑ