nuxt-modules / apollo

Nuxt.js module to use Vue-Apollo. The Apollo integration for GraphQL.
https://apollo.nuxtjs.org
MIT License
929 stars 194 forks source link

Support for defining custom links #563

Open bmulholland opened 8 months ago

bmulholland commented 8 months ago

Your use case

We're upgrading to Nuxt 3 from Nuxt 2. When upgrading Nuxt Apollo, I see there's no longer any way to pass in our custom ApolloLink. We already had this working using a complex link chain, which supports both file uploads (ref: https://github.com/nuxt-modules/apollo/issues/553) but also has a custom link for websockets via Rails Action Cable.

Removing this option is backwards-incompatible. We'll have to do the same as others and write our own plugin, I guess. Then we'll have to maintain that ourselves, too, which I prefer not to do.

The solution you'd like

Allow overriding links, like used to be available.

Possible alternatives

No response

Additional information

No response

ashotmark commented 6 months ago

hi @bmulholland , I had same issue in the project that I work. in the project, We used nuxt3 and nuxt apllo (this module). We need to have custom link for to add support csrf link for security and pusher based subscription for real time data. I went through documentation and source code and realized that there is no way to have custom link by config or plugin that this module exposed so far. As a solution, I had to fork repo and changed source code to support custom link as our needs and published into own npm. So this could work in our project, please let me know if you have more questions. Thank you

bmulholland commented 6 months ago

Thanks for the idea, Ashot :). On my end, I ended up just dropping Nuxt Apollo and configuring it directly myself. That was easy because we don't use SSR.

ashotmark commented 6 months ago

Got you, as long as not SSR, no need to use nuxt apollo, and I am sure that your solution is the best. thanks for reply, hope all good 👍

rschmied commented 6 months ago

Hey Brendan -- are you then using https://github.com/Akryum/vue-cli-plugin-apollo direct? I am in the same boat but ended up writing a plugin which works around this limitation but still using the module (to some extent). It works but I have the feeling that it's not needed as I have deviated far enough from the "simple" use case of the nuxt module.

bmulholland commented 6 months ago

I'm on Vue 3/Vite now, which drops Vue CLI support, so it's https://github.com/vuejs/apollo directly.