I try to include nested types defined in the following graphql schema:
type User {
id: String!
posts: [Post]
}
type Post {
id: String!
}
type Query {
getUser(id: String!): User
getPost(id: String!): Post
}
As you can see a User has multiple Posts. I am using AppSync with an Adjacent List Dynamodb Table (which contains both the User and the Post relevant row) as a data source. Within AppSync I have to use a request mapping template, but after reading the documentation I have not understood how nested types are resolved?
I would imagine that on querying getUser
the Post resolver should be called with the User_id. If so how do I access the parent id within the post resolver? Is this where ${context.source}
comes into place?
As the getPost
query resolver would be the same as the Post resolver, called by the getUser Post child, would I have to integrate some logic with request template of the resolver to deal with both cases?
An example would be really helpful!