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

Error: Invalid AST Node: null. - NUXT3 #564

Open alessioraggioli opened 8 months ago

alessioraggioli commented 8 months ago

Environment

"@nuxtjs/apollo": "^5.0.0-alpha.8",

Describe the bug

Sometimes I get randomly this error when trying to call graphql method.

I have a composable function

export async function GQL_REQUEST(query) {
  try {
    const { data, refresh, error } = useAsyncQuery(query)
    if (!data.value) {
      //on alpha.5 bug fixing, forse puoi rimuovere appena passa a beta/stable
      return refresh()
        .then(() => {
          return JSON.parse(JSON.stringify(data.value))
        })
        .catch((err) => {
          log('////////GRAPHQL ERROR REFRESH METHOD', true)
          log(query.loc.source)
          log(err)
        })
    } else {
      return data.value
    }
  } catch (err) {
    log('////////GRAPHQL ERROR AT INIT', true)
    log(err)
  }
}

this is the error in console

Error: Invalid AST Node: null. at devAssert (devAssert.mjs:5:11) at visit (visitor.mjs:168:23) at print (printer.mjs:10:10) at prep (composables.mjs?v=03ae6653:24:47) at useAsyncQuery (composables.mjs?v=03ae6653:7:23) at GQL_REQUEST (gqlRequest.js:3:38) at Proxy.getDocumentByTipoUd (index.js:134:20) at Proxy. (pinia.mjs:1362:30) at store. (pinia.mjs:915:40) at index.vue:329:37

Expected behaviour

query works

Reproduction

No response

Additional context

No response

Logs

No response

pschaub commented 6 months ago

Could you provide a complete example of how to reproduce this issue? The example you mentioned does not seem to be complete, as e.g. the query is not specified and could possibly be the cause.