A community of developers, designers and others who love Apollo and GraphQL. 🚀


Query returning empty array

July 27, 2020 at 4:08pm

Query returning empty array

July 27, 2020 at 4:08pm
Hi all, I just installed and setup apollo-angular, successfuly tested that it's receiving data from the back-end, but I'm receiving an empty array for the data. Code looks like:
const getGoal = gql`
query GetGoal($survey_id: String!) {
goals(where: { survey_id: { _eq: $survey_id } }) {
....constructor, etc.....
ngOnInit() {
query: getGoal,
variables: {
survey_id: 'test_survey'
.valueChanges.subscribe(({ data, loading }) => {
this.loading = loading;
this.goal = data.goal;
I've tested this query on the backend (Hasura), and it's working as I expect it. Permissions are configured so that it's accessible, I'm not getting any console errors. Any insight would be appreciated!

August 5, 2020 at 5:26pm
I believe the problem is on your last line. "this.goal = data.goal". The object you are querying is goals with an s not goal. Try changing to "this.goal = data.goals"
  • reply
  • like
This turned out to be a matter of relationships nto fully set up, disregard!
  • reply
  • like