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 v3 #174

Closed
mackattack3k opened this issue Jan 30, 2020 · 23 comments · Fixed by #175
Closed

Support @apollo/client v3 #174

mackattack3k opened this issue Jan 30, 2020 · 23 comments · Fixed by #175

Comments

@mackattack3k
Copy link

Do you have any plans to support ApolloLink from @apollo/client v3?

See documentation of it here https://www.apollographql.com/docs/react/v3.0-beta/api/link/introduction/

@jaydenseric
Copy link
Owner

Yes, once it is released we will update this package to support it. Because this would be a breaking change for people using Apollo Client v2 we have to wait for v3 to come out of beta.

The @apollo/client v3 milestone can be tracked here:

https://github.com/apollographql/apollo-client/milestone/14

@danieldunderfelt
Copy link

It seems to work as well as before for me.

@sgentile
Copy link

@jaydenseric I'm using @apollo/client beta v3 and getting this error:

Type 'ApolloLink' is missing the following properties from type 'ApolloLink': onError, setOnError TS2739

const apolloClient = new ApolloClient({
link: createUploadLink({
uri: '/api',
headers: {
authorization: token ? Bearer ${token} : '',
},
}),
cache: new InMemoryCache(),
});

@sapkra
Copy link

sapkra commented Jun 6, 2020

@jaydenseric FYI: It's out of beta now. The current state is rc.2 so it seems to be released soon.

@Vultraz
Copy link

Vultraz commented Jun 6, 2020

Will there be a package name change (@apollo/link-upload for example) or will this remain apollo-upload-client?

@sapkra
Copy link

sapkra commented Jun 6, 2020

@Vultraz I think it will stay apollo-upload-client because to publish to @apollo you have to be a member of apollo's npm organization.

@dohomi
Copy link

dohomi commented Jun 30, 2020

Any hints on how to do the setup with the latest rc-9 of apollo-client?

@jaydenseric
Copy link
Owner

In addition to waiting for Apollo to release v3, you can track these PRs:

@dohomi
Copy link

dohomi commented Jun 30, 2020

@jaydenseric thanks for your info, I hope there can be an initial example soon. Confused why apollo-client still didn't built the functionality into the core after v3 rewrite

@cr1979
Copy link

cr1979 commented Jul 13, 2020

Hello,
I run in a little problem. We are using apollo client V3 in our project and now we have to use a file upload with graphql. There current version isn't working with V3. Is there a quick and dirty solution to get this to work with V3.
Or I have to downgrade to version 2. But this is not easy way because of all hooks we're using.
The developer who used V3 is gone. So I'm a bit lost and the customer is waiting for our release.

I know never use a beta in a prod project. Was not my idea.

We're using React Native and TypeScript btw.

Error: Type 'ApolloLink' is missing the following properties from type 'ApolloLink': onError, setOnError TS2739

Thank you.

@sapkra
Copy link

sapkra commented Jul 13, 2020

@cr1979 Can you try using my fork? It should be possible to install it via github. It's based on the open PR.

"apollo-upload-client": "github:sapkra/apollo-upload-client#apollo-client-v3-self-build"

@cr1979
Copy link

cr1979 commented Jul 13, 2020

@sapkra perfect I will give it a try, tomorrow. I'll let you know. Thanks a lot.
What's about the type definition file for typescript (@types\apollo-upload-client)?

@jaydenseric
Copy link
Owner

I'm working on this today and potentially tomorrow (Melbourne, Australia time) in anticipation of Apollo Client v3 releasing today/tomorrow.

@jaydenseric
Copy link
Owner

It's a bit difficult to figure out the earliest @apollo/client pre-release version to declare support for in peerDependencies because it appears there is no log of breaking changes in v3 pre-release versions.

There are no descriptions for GitHub releases:

https://github.com/apollographql/apollo-client/releases

Screen Shot 2020-07-14 at 6 01 34 pm

There are no individual changelog entries for v3 prerelease versions:

https://github.com/apollographql/apollo-client/blob/master/CHANGELOG.md#apollo-client-300-tbd---not-yet-released

Screen Shot 2020-07-14 at 6 02 41 pm

@Vultraz
Copy link

Vultraz commented Jul 14, 2020

Wouldn't 3.0.0 final be best? The RC ones are probably full of bugfixes.

@cr1979
Copy link

cr1979 commented Jul 14, 2020

@sapkra I tried your fork but I get these errors:

npm ERR! prepareGitDep 1> 
npm ERR! prepareGitDep > [email protected] postinstall C:\Users\CR\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-149ed5ce\node_modules\ejs
npm ERR! prepareGitDep > node ./postinstall.js
npm ERR! prepareGitDep
npm ERR! prepareGitDep Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)
npm ERR! prepareGitDep
npm ERR! prepareGitDep
npm ERR! prepareGitDep > [email protected] prepare C:\Users\CR\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-149ed5ce
npm ERR! prepareGitDep > npm run prepare:clean && npm run prepare:js && npm run prepare:jsdoc && npm run prepare:prettier
npm ERR! prepareGitDep
npm ERR! prepareGitDep
npm ERR! prepareGitDep > [email protected] prepare:clean C:\Users\CR\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-149ed5ce
npm ERR! prepareGitDep > rm -rf lib
npm ERR! prepareGitDep 
npm ERR! prepareGitDep
npm ERR! prepareGitDep 2> npm WARN install Usage of the `--dev` option is deprecated. Use `--only=dev` instead.
npm ERR! prepareGitDep npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm ERR! prepareGitDep npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm ERR! prepareGitDep npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm ERR! prepareGitDep npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm ERR! prepareGitDep Der Befehl "rm" ist entweder falsch geschrieben oder
npm ERR! prepareGitDep konnte nicht gefunden werden.
npm ERR! prepareGitDep npm ERR! code ELIFECYCLE
npm ERR! prepareGitDep npm ERR! errno 1
npm ERR! prepareGitDep npm ERR! [email protected] prepare:clean: `rm -rf lib`
npm ERR! prepareGitDep npm ERR! Exit status 1
npm ERR! prepareGitDep npm ERR!
npm ERR! prepareGitDep npm ERR! Failed at the [email protected] prepare:clean script.
npm ERR! prepareGitDep npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! prepareGitDep
npm ERR! prepareGitDep npm ERR! A complete log of this run can be found in:
npm ERR! prepareGitDep npm ERR!     C:\Users\CR\AppData\Roaming\npm-cache\_logs\2020-07-14T13_45_58_958Z-debug.log
npm ERR! prepareGitDep npm ERR! code ELIFECYCLE
npm ERR! prepareGitDep npm ERR! errno 1
npm ERR! prepareGitDep npm ERR! [email protected] prepare: `npm run prepare:clean && npm run prepare:js && npm run prepare:jsdoc && npm run prepare:prettier`
npm ERR! prepareGitDep npm ERR! Exit status 1
npm ERR! prepareGitDep npm ERR!
npm ERR! prepareGitDep npm ERR! Failed at the [email protected] prepare script.
npm ERR! prepareGitDep npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! prepareGitDep
npm ERR! prepareGitDep npm ERR! A complete log of this run can be found in:
npm ERR! prepareGitDep npm ERR!     C:\Users\CR\AppData\Roaming\npm-cache\_logs\2020-07-14T13_45_59_033Z-debug.log
npm ERR! prepareGitDep
npm ERR! premature close

@jaydenseric
Copy link
Owner

@cr1979 that's because you're using Windows, which isn't supported for dev because it doesn't support unix commands like rm out of the box. See #183 (comment) for more context.

@cr1979
Copy link

cr1979 commented Jul 14, 2020

@jaydenseric yes I saw that :( I'm currently using the computer from my company. I can't switch to linux currently. Hmmm, what's the plan. Wait till you have a new apollo-client-upload release or I have to downgrade to Apollo v2.
What do you think how long do you need?

@sapkra
Copy link

sapkra commented Jul 14, 2020

@cr1979 Because I already have the prebuild lib in my fork you can just use it without building it locally again. I'm using yarn which has a bug that the prepare script are not executed if the package is coming from a git repo. To fix your problem I removed all scripts now and bumped the version to alpha.2. Can you try it again?

@cr1979
Copy link

cr1979 commented Jul 14, 2020

@sapkra I tried it and I could install it. Now I have to create a type definition file for typescript. But I will try it in the company again, tomorrow.
Thanks a lot. Hope I can upload files soon. :)

@robphoenix
Copy link

As an aside to this issue, for anyone like me arriving here needing to upload files with apollo v3, I've sidestepped this by encoding the file contents as a base64 string and then sending that and the filename, decoding the file contents on the server and writing them to a file.

@cr1979
Copy link

cr1979 commented Jul 14, 2020

@robphoenix that was my original plan of uploading file to the server. But I have a GraphQL message limit of 100kb. I know that the default settings but I had no chance to raise the limit. We are using Molecular Apollo Server and the setting will be ignored.

bodyParsers: {
      json: true,
      urlencoded: { extended: true, limit: '5mb' }
},

so my hope I'll get this fixed with apollo-upload-client.

I tried it with Insomnia and I can stream files to the server as multipart so far.

@jaydenseric
Copy link
Owner

Does anyone know if babel-plugin-graphql-tag works out of the box with gql imported as a named import from @apollo/client?

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 a pull request may close this issue.

9 participants