apollo
apollo copied to clipboard
Support for Nuxt new fetch()?
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.
@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
Yes totally, but shouldn't smart queries default to use fetch() now?
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.
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.
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.
@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 Just checking in on this, any news?