why is this gql apolllo client not working not exrtracting data correctly in the computed( ) from vue 3?

Viewed 10

This is the query:

    const { result } = useQuery(
      gql`
        query RatingHistory(
          $ratingHistoryFilter: userRatingHistoryFilterInput!
          $id: String!
        ) {
          getUser(_id: $id) {
            ratingHistory(ratingHistoryFilter: $ratingHistoryFilter) {
              date
              rating
            }
          }
        }
      `,
      {
        id: '62c2d4100892074470ca374e',
        ratingHistoryFilter: {
          dateFrom: '1994-06-12',
          dateTo: '2022-07-10',
          verified: 'false'
        }
      }
    )

I know it's all hardcoded ( just testing for the moment )

so.. if i do: console.log(result.value) => i got a ref with a array of 4 elements.

But when I do this:

const ratingData = computed(() => result.value?.ratingHistory ?? [])
    console.log(ratingData.value)

the result is => [] => Empty Array

I'm practically sure that the error is in the name after result.value?..... ?? [] => ratingHistory must not be correct but I can't hit the right one.

If you need any extra data like the server query or any other images/code just tell me. Thank you!

0 Answers
Related