Reputation: 29
I am following this tutorial https://strapi.io/blog/nextjs-react-hooks-strapi-restaurants-2
My query is
{
restaurants {
id
name
}
}
Response
{
"error": {
"errors": [
{
"message": "Cannot query field \"id\" on type \"RestaurantEntityResponseCollection\".",
"locations": [
{
"line": 3,
"column": 5
}
],
"extensions": {
"code": "GRAPHQL_VALIDATION_FAILED",
"exception": {
"stacktrace": [
"GraphQLError: Cannot query field \"id\" on type \"RestaurantEntityResponseCollection\".",
Upvotes: 1
Views: 2435
Reputation: 85
Below solution worked for me
Strapi changes Goto - settings-> Roles-> Public-> Permissions section
In this section you need to enable your collection methods, e.g.- find, update, delete and find one
Upvotes: 0
Reputation: 81
You query is incorrect, it should be as follow docs:
{
restaurants{
data{
id
attributes{
name
image{
data{
attributes{
url
}
}
}
}
}
}
}
Upvotes: 4
Reputation: 61
New strapi versions doesnt work with that old tutorials
{
restaurants {
data {
id
attributes {
name
description
}
}
}
}
It will resolve data like this:
{
"data": {
"restaurants": {
"data": [
{
"id": "1",
"attributes": {
"name": "name 1",
"description": "desc 1"
}
},
{
"id": "2",
"attributes": {
"name": "name 2",
"description": "desc 2"
}
}
]
}
}
}
Upvotes: 3