Nuxt.js: nuxt connecting to graphql apollo client

Created on 18 Dec 2016  路  4Comments  路  Source: nuxt/nuxt.js

Hello,
Is there a way to fetch data on each reload from a graphql apollo client and render its content based on the data it is fetching? Would be very interested in an example.
Thanks

This question is available on Nuxt.js community (#c53)
question

Most helpful comment

Hi @dohomi

First, to make the apollo-client works on the server-side, you need to polyfill fetch, you can do it by installing the isomorphic-fetch module.

Then, you need the apollo-client and graphql-tag module. you can add them in your nuxt.config.js file in the build.vendor section.

I created an example for you so you can see how it works: https://gomix.com/#!/project/nuxt-apollo-client
Live demo: https://nuxt-apollo-client.gomix.me/

I created the ~plugins/apolloClient.js to create the connection and re-use it in every pages components.

All 4 comments

Hi @dohomi

First, to make the apollo-client works on the server-side, you need to polyfill fetch, you can do it by installing the isomorphic-fetch module.

Then, you need the apollo-client and graphql-tag module. you can add them in your nuxt.config.js file in the build.vendor section.

I created an example for you so you can see how it works: https://gomix.com/#!/project/nuxt-apollo-client
Live demo: https://nuxt-apollo-client.gomix.me/

I created the ~plugins/apolloClient.js to create the connection and re-use it in every pages components.

Great stuff, thanks @Atinux

There is this plugin https://github.com/nuxt-community/apollo-module which you can use.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VincentLoy picture VincentLoy  路  3Comments

surmon-china picture surmon-china  路  3Comments

vadimsg picture vadimsg  路  3Comments

vadimsg picture vadimsg  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments