I just started exploring graphql, so am running in to initial problems using the framework. The code used on this post is hosted on github @ https://github.com/samshers/graphQL-Starter
The graphql schema of my api is as below:
schema {
query: Query
}
type Query {
allCities: [City]
city(name: String): City
state(name: String): State
}
type City {
name: String
population: String
state: State
}
type State {
name: String
population: String
country: Country
cities : [City]
}
type Country {
name: String
population: String
}
The query I am trying to execute is -
{
city(name: "BayArea") {
name
population
state {
name
population
cities {
name
}
country {
name
population
}
}
}
}
and the result I am getting is -
{
"errors": [],
"data": {
"city": {
"name": "BayArea",
"population": "7200000",
"state": {
"name": "CA",
"population": "39900000",
"cities": [],
"country": {
"name": "USA",
"population": "330000000"
}
}
}
},
"extensions": null
}
The problem is with this part of the result -
"population": "39900000",
"cities": [],
"country": {
I did expect the cities array to be populated accordingly with all the cities available for the particular state.
Will appreciate if anyone can point out if the issue is with the schema/query or jpa mapping. As stated earlier the code is hosted on github @ https://github.com/samshers/graphQL-Starter