Home

Issue: 2254

generate routes using Apollo in nuxt.config.js

[issue link]

I am looking to generate certain routes from Apollo (GraphQL) not using Axios, which all demo’s seem to use.

...
  apollo: {
    networkInterfaces: {
      default: '~/apollo/network-interfaces/default.js'
    },
    clientConfigs: {
      default: '~/apollo/client-configs/default.js'
    },
    allArticles: {
      query: '~/apollo/queries/allArticles'
    }
  },
  generate: {
    routes: function () {
      return allArticles.data.map((article) => {
        return {
          route: '/articles/' + article.id,
          payload: article
        }
      })
    }
...

The issue is I am not able to access ‘allArticles’

Generating routes
Could not resolve routes
TypeError: Cannot read property 'data' of undefined

I am able to do this on my Vue Component but not sure if there is anything special I need for using it in the nuxt.config.js

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