I have two types: Todo and Comment.
type Todo {
id: ID!
name: String
description: String
priority: Int
status: TodoStatus
comments: [Comment]
}
type Comment {
todoid: ID!
commentid: String!
content: String
}
Then I have a Query getTodo but the thing is I want to include a content arg that filters the comment (child) if the string passed is in the content of Comment.
getTodo(id: ID!, content: String!): Todo
I have tried attaching a resolver to comments (under Todo). If I add a filter here, how will I be able to get the ctx.args.content which was passed in getTodo(id: ID!, content: String!).
{
"version" : "2017-02-28",
"operation" : "Query",
"query" : {
## Provide a query expression. **
"expression": "todoid = :id",
"expressionValues" : {
":id" : {
"S" : "${ctx.args.id}"
}
}
},
"filter": {
"expression": "contains(content, :content)",
"expressionValues" : {
":content": {
"S": "${ctx.args.content}"
}
}
}
}
Or if I remove this filter and leave it like this:
{
"version" : "2017-02-28",
"operation" : "Query",
"query" : {
## Provide a query expression. **
"expression": "todoid = :id",
"expressionValues" : {
":id" : {
"S" : "${ctx.args.id}"
}
}
}
}
How will I modify getTodo Resolver to fetch comments (with content that contains the string passed)? Can I do it like this (accessing if comments.content contains the content string args passed):
{
"version" : "2017-02-28",
"operation" : "Query",
"query" : {
## Provide a query expression. **
"expression": "id = :id",
"expressionValues" : {
":id" : {
"S" : "${ctx.args.id}"
}
}
},
"filter": {
"expression": "contains(comments.content, :content)",
"expressionValues" : {
":content": {
"S": "${ctx.args.content}"
}
}
}
}