DEV Community

Discussion on: Building blog CMS in ReasonML with GraphQL and Serverless using Hasura

Collapse
 
idkjs profile image
Alain

Looks like you don't have the user field set up on posts type. You have user_id so how would you return the name and avatar from the users table?

this query doesnt work if i have the same set up as you:

query getPosts {
  posts {
    title
    cover_img
    content
    created_at
    user {
      name
      avatar_url
    }
  }
}

Collapse
 
idkjs profile image
Alain

Solution is tracking the foreign keys on your tables. See:docs.hasura.io/1.0/graphql/manual/...

Collapse
 
vladimirnovick profile image
Vladimir Novick

Not exactly. an easier solution is what I wrote. You need to add relationships in relationships tab. I added a screenshot to clarify