davazp / graphql-mode

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

Could I define graphql url in .graphql text file? #21

Closed liuchong closed 5 years ago

liuchong commented 5 years ago

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!

davazp commented 5 years ago

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.

liuchong commented 5 years ago

@davazp Thanks!

liuchong commented 5 years ago
# 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

davazp commented 5 years ago

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

liuchong commented 5 years ago

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.

davazp commented 5 years ago

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

liuchong commented 5 years ago

It works now, thanks! :cat: