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

Support apollo-client v2 #33

Closed
AdamYee opened this issue Sep 24, 2017 · 12 comments
Closed

Support apollo-client v2 #33

AdamYee opened this issue Sep 24, 2017 · 12 comments

Comments

@AdamYee
Copy link

AdamYee commented Sep 24, 2017

Hi Jayden!

I think I may have read you're already working on this (i.e. creating a custom Link)? Do you need any help with this? https://github.com/apollographql/apollo-link/blob/master/docs/implementation.md

Adam

@jaydenseric
Copy link
Owner

jaydenseric commented Sep 24, 2017

apollo-upload-fetch is good to go; it supersedes apollo-upload-client for apollo-client v2. I have been using the new link based network interface for a while now, you can see how it works together in apollo-upload-examples.

If you would like to help out, the examples could do with an update to apollo-client v2. The upgrade guide has been improved since I got stuck on some getInitialState API changes. I'm waiting for a new release of react-apollo that has an apollo-client v2 dependency before upgrading my own app, to avoid multiple versions of apollo-client getting bundled.

@jaydenseric
Copy link
Owner

An update: Apollo Link now uses the native fetch implementation instead of apollo-fetch. Once I am sure of the situation I'll likely update apollo-upload-client for Apollo Client v2 sometime soon (within the next week hopefully) and deprecate apollo-fetch-upload. Only the setup for Apollo Client will change; everything else should work the same as before.

@jaydenseric jaydenseric reopened this Oct 23, 2017
@jaydenseric jaydenseric changed the title Plans for apollo-client 2.0? Support apollo-client v2 Oct 23, 2017
@jaydenseric
Copy link
Owner

I have been working on an upload link for Apollo Client v2 (keep an eye on the next branch) but it has been trickier than I anticipated.

In the meantime, apollo-fetch-upload works fine with Apollo Client v2, and if you use batching you will still need to use apollo-fetch for a while anyway. I am focusing on a new generation spec for multipart GraphQL requests along with a new version of apollo-upload-server for now.

@leethree
Copy link

leethree commented Nov 6, 2017

apollo-fetch-upload works fine with Apollo Client v2

Hi @jaydenseric , could you provide an example for that? I can't seem to make it work using Apollo v2 without batching.

@AdamYee
Copy link
Author

AdamYee commented Nov 6, 2017

I think it would be fine to have a separate publish for an apollo-link-batch-upload.

@jaydenseric
Copy link
Owner

I've got a non-batching upload terminating link working in the next branch.

With a bit more polish and testing we'll be able to publish a beta.

The API diverges slightly from apollo-link-http:

@jaydenseric
Copy link
Owner

@leethree I don't have an example handy sorry, I have never not used batching. Perhaps it is not easy or possible, in which case it might be best to use batching until this update is published.

This is something like my 4th implementation of uploads for Apollo Client 😓

@vladshcherbin
Copy link

vladshcherbin commented Nov 7, 2017

@jaydenseric hey, since new apollo packages are growing like mushrooms after rain, what's the best way to do file uploads now? What stable packages combo would you suggest and with or without batching?

p.s. sorry you have to re-implement this every time apollo decides to change internals, it really sucks.

@jaydenseric
Copy link
Owner

Just published v6.0.0-beta.1 🚀

It does not require any changes to your codebase other than a new Apollo Client setup. I'll update apollo-upload-examples shortly.

Unfortunately batching is not available in this release; hopefully we can support it soon in an update. I'm waiting on a solid batching link from Apollo to reference. If you desperately need batching, you can continue to use apollo-fetch-upload with apollo-link-batch-http@^1.

@jaydenseric
Copy link
Owner

Updated apollo-upload-examples: Here is the new Apollo Client setup.

Closing this now we support the final Apollo Client v2 API. I will raise a new issue to add back batching support. Please everyone test out the beta and raise any issues so we can rush it into production 🙌

@Fi1osof
Copy link

Fi1osof commented Feb 4, 2018

There is a confusing ResponseError type used in a few places that does not seem to be a documented part of the Apollo Link API, i.e. important to apollo-link-error. I chose not to adopt it and the way several errors are thrown.

Why not return raw apollo error? I can not catch GraphQL errors. In raw error object exists:
operation: The Operation that errored
response: The result returned from lower down in the link chain
graphQLErrors: An array of errors from the GraphQL endpoint
networkError: Any error during the link execution or server response, that wasn’t delivered as part of the errors field in the GraphQL result

In apollo-upload-client just operation, graphQLErrors (null), networkError. response required.

@jaydenseric
Copy link
Owner

@Fi1osof see #47 (comment).

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

No branches or pull requests

5 participants