Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for async requests #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Malabarba
Copy link
Contributor

I did this mostly because request.el is bugged for me on synchronous requests. But I think it's a nice addition anyway (it has bothered me many times before that emacs would hang while the request is running, specially when I setup some debugging breakpoints in the server).

Hope you find this useful.

Thanks a lot for this package.

@@ -146,8 +153,9 @@ Please install it and try again."))
:type "POST"
:data body
:headers headers
:parser 'json-read
:sync t
:parser 'buffer-string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the parser is an independent change. Instead of calling json-read here only to call json-encode later, we can just take the buffer contents and no do any encoding/decoding.

Copy link
Owner

@davazp davazp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! That is a nice improvement.

I think I'd like a small change.

I would like to keep a function that is useful to make requests programatically. Before this change, that function was graphql--query and graphql-post-request. But now the callback in them means you can't build your own functions on top of it.

I'd propose to add two arguments sync and success callback arguments to them, and only pass the callback from the interactive graphql-send-query function.

Then it is probably a good idea to still keep the :parser 'json-read. But feel free to add still another argument to it and pass buffer-string from the query if you want.

Hm, with those changes, I also feel comfortable of making the interactive function always async and not even introduce a custom.

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants