nuxt-graphql-client icon indicating copy to clipboard operation
nuxt-graphql-client copied to clipboard

the error thrown by useAsyncGql will result in null data

Open NewYorkDoll opened this issue 2 years ago • 2 comments

hi @Diizzayy

I have a GQL res data body

CLICK ME

{
  "errors": [
    {
      "message": "not authenticated",
      "path": [
        "self"
      ]
    }
  ],
  "data": {
    "self": null,
    "githubUser": {
      "login": "NewYorkDoll",
      "name": "yiziluoying",
      "avatarURL": "https://avatars.githubusercontent.com/u/70010012?v=4",
      "bio": "Just so so",
      "email": null,
      "location": null,
      "htmlurl": "https://github.com/NewYorkDoll"
    },
    "version": {
      "commit": "n/a",
      "goVersion": "go1.19.1",
      "date": "n/a"
    },
    "codingStats": {
      "totalDuration": "11 hrs 6 mins",
      "totalSeconds": 39960,
      "calculatedDays": 30,
      "languages": [

      ]
    }
  }
}
const { data, error } = await useAsyncGql('base')
// data = null
/** 
 error =     {
      "message": "not authenticated",
      "path": [
        "self"
      ]
    }
*/

I expect data data to be available normally, just like GQL res, instead of being null.

my queries

query base {
  self {
    id
    name
    login
    avatarURL
  }

  githubUser {
    login
    name
    avatarURL
    bio
    email
    location
    htmlurl
  }
  version {
    commit
    goVersion
    date
  }

  codingStats {
    totalDuration
    totalSeconds
    calculatedDays

    languages {
      language
      totalSeconds
    }
  }
}

NewYorkDoll avatar Sep 28 '22 02:09 NewYorkDoll

Same problem. No update on this? UPD: In my case, I solved it by adding: useGqlHeaders({ Accept: 'application/json' });

j-tap avatar Dec 13 '22 22:12 j-tap

Same problem. No update on this?

talaxasy avatar Feb 24 '23 00:02 talaxasy