apollo icon indicating copy to clipboard operation
apollo copied to clipboard

Support for Nuxt new fetch()?

Open drewbaker opened this issue 4 years ago • 7 comments

What problem does this feature solve?

It would be great if this could use the new Nuxt fetch() API so that smart queries would be SSR'd at all component levels (not just on Pages like it does currently).

What does the proposed changes look like?

I imagine that you'd want to make this use the new fetch() be default as it doesn't have any breaking changes. Perhaps you'd have a config option to use the old way for people upgrading Nuxt-Apollo for other needs.

This feature request is available on Nuxt community (#c308)

drewbaker avatar Apr 20 '20 18:04 drewbaker

@drewbaker I'm sure you can use the same code as in the asyncData example. https://github.com/nuxt-community/apollo-module#asyncdatafetch-method-of-page-component

dohomi avatar Apr 22 '20 05:04 dohomi

Yes totally, but shouldn't smart queries default to use fetch() now?

drewbaker avatar Apr 22 '20 18:04 drewbaker

In my knowledge the fetch is just a NuxtJS API on component/page level run SSR code: https://github.com/nuxt/nuxt.js/blob/dev/examples/new-fetch/components/Author.vue#L20 So the example https://github.com/nuxt-community/apollo-module#asyncdatafetch-method-of-page-component is still valid.

dohomi avatar Apr 23 '20 01:04 dohomi

Well the advantage of fecth() is that it doesn't have to be at the page level to be SSR's. It can be on a deep component and still be SSR'd. Would be great if smart query's used fetch() so that anything could be SSR'd.

drewbaker avatar Apr 23 '20 22:04 drewbaker

I believe that we nuxt plugin have'nt support fetch yet. We only have beforeNuxtRender in the plugin context. So this is have to be supported by nuxt itself to be done.

kieusonlam avatar Apr 24 '20 00:04 kieusonlam

@Atinux @alexchopin could you shade some light to this topic? I would guess that from the new fetch in any component level all the code runs in SSR mode. Would that mean that https://github.com/nuxt-community/apollo-module#asyncdatafetch-method-of-page-component works out of the box?

@drewbaker can you open a simple repo to showcase the scenario?

dohomi avatar Apr 24 '20 01:04 dohomi

@dohomi Just checking in on this, any news?

wirsing avatar Oct 07 '20 00:10 wirsing