graphql-ruby-demo
graphql-ruby-demo copied to clipboard
Query requires edges
https://github.com/rmosolgo/graphql-ruby-demo/blob/master/app/graph/queries/readLukesFriends.graphql
Running this query
query readLukesFriends {
luke: human(id: 1000) {
friends { name }
}
}
http://graphql-ruby-demo.herokuapp.com/graphiql?query=%7B%0A%20%20luke%3A%20human(id%3A%201000)%20%7B%0A%20%20%20%20friends%20%7B%20name%20%7D%0A%20%20%7D%0A%7D
Returns
"Field 'name' doesn't exist on type 'CharacterConnection'"
But this query works:
luke: human(id: 1000) {
friends {
edges {
node {
name
}
}
}
}
Because friends is a connection. According to Relay Connections Specification, connections must contain an edges field, which is a list type. You can also checkout the type definition here. https://github.com/rmosolgo/graphql-ruby-demo/blob/master/app/graph/types/human_type.rb
@mumuWeng Is there any chance this query will work?
query readLukesFriends {
luke: human(id: 1000) {
friends { name }
}
}
What changes need to be made on human_type.rb ?