strapi 4 Nuxt and Graph QL

Viewed 11

Trying to return a single record from STRAPI in NUXT

In the playground this works

query {
  organisation(id: 1) {
    data {
      id
      attributes {
        name
      }
    }
  }
}

So I added this to my apollo/queries/organisation/organisation.gql file as follows

query Organisations ($id: ID!) {
    organisation(id: $id) {
    data {
      id
      attributes {
        name
        level
      }
    }
  }
}

I am trying to test this by just passing the ID as follows

<script>
import organisationsQuery from '@/apollo/queries/organisation/organisation'
export default {
  data() {
    return {
      loading: 0,

      organisation: {
        data: [],
      },
    }
  },
  apollo: {
            organisations: {
                prefetch: false,
                query: organisationsQuery,
                    variables() {
                        return {id: 1};
                    },
            },
        },
}
</script>

I get the errors

Missing organisations attribute on result 

can anyone tell me what I am doing wrong please

0 Answers
Related