-
Notifications
You must be signed in to change notification settings - Fork 19
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
Port to elm/http 2.0.0 #42
base: master
Are you sure you want to change the base?
Conversation
|> Http.toTask | ||
|> Task.mapError (Util.convertHttpError HttpError GraphQLError) | ||
Err err -> | ||
Err (HttpError (Http.BadBody (Json.Decode.errorToString err))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might make sense to also now flatten the Error
type instead of nesting Http.Error
.
I'm more than willing to see through the work to get this landed, but I'd like to get some feedback before I keep diving in. Thanks for your time. |
Thanks for this! I haven't looked closely at elm/http-2.0.0 yet, but if the update requires a major version bump then I think it might be good to bundle up bigger changes to error handling as well. I will try to take a closer look at this soon and get back to you with ideas for how to move forward. |
I started working on elm/http@2 support as well, with the same motivation to support trackable file uploads. See https://github.com/klaftertief/elm-graphql/tree/elm-http-2 In elm/http there are now separate APIs for "normal" and "risky" request (withCredentials). I added a |
Yeah, I saw that as well. I like that change personally. What I was exploring was, instead of trying to wrap the various variations of Http.post
{ url = "/graphql"
, body = graphQLBody request
, expect = expectGraphQL request GotQueryResponse
} That just needs one more helper: graphQLBody request =
postBody (Builder.requestBody request) (Builder.jsonVariableValues request) where request is |
Sounds like a good plan. )I do not really like my changes.) |
Yeah, I just wanted an endorsement that @jamesmacaulay likes the approach before spending much time on it. |
@vodik I like that approach of just giving people good building blocks to make their own requests, I considered it before but it's looking like it makes more and more sense now. Error handling is the biggest question mark in my mind, but I think it should be done with the same philosophy: just make good building blocks available instead of trying to make a one-size-fits-all wrapper. |
Awesome. I'll try and get this done over the weekend then. |
Hello, any update on this? |
@vodik @klaftertief I take it, for whatever reason, you have not been able to progress in this work? Have you gone to a different GraphQL client library, or do you have any other recommendations for folks needing to upgrade to elm/http 2.0? |
@sentience We had a patched version for some time in our project and switched to |
Hello 👋 is there any plan to work on this port? I'd be glad to help! |
So, I don't expect these changes to get accepted anywhere near as is, but might as kick off some discussion around how to port to the newer http package.
I personally need the new file upload support included in the newer package, and with these patches everything seems to work for me.
This code is very rough and kludgy - I was focused on getting things working first and foremost. I'm planning on continuing working on this patch and got some ideas of how things might need to be changed. So, a couple of notes:
The
Http.request
method now returns aCmd
directly, with theExpect
type creating the result directly. Tasks are still supported throughHttp.task
now, but requires working with aResolver
type. I wonder if we should copy this API (e.g. something likesendQuery
andqueryTask
)It might make sense to add and expose a
expectGraphQL
(forExpect
) and (graphQLResolver
forResolver
) and glue error handling directly in there instead of having to map it.