I am experimenting with GraphQL, AppSync and AWS Amplify for a new project. Let's say I have the following schema:
type Test @model {
id: ID!
name: String
text_pieces: [String]
}
Now, I have created this through Amplify and it automatically generates queries like ListTests which accepts filtering. Filtering accepts lots of useful operators such as beginsWith or contains. Let's say I have these objects as data source:
[
{
"name": "FirstTest",
"text_pieces": [
"FirstPiece",
"SecondPiece"
]
},
{
"name": "SecondTest",
"text_pieces": [
"ThirdPiece",
"FourthPiece"
]
}
]
So I can build a query like:
query FirstTests {
listTests(filter: {name: {beginsWith: "First"}}) {
items {
name
text_pieces
}
}
}
Which returns, as expected:
{
"name": "FirstTest",
"text_pieces": [
"FirstPiece",
"SecondPiece"
]
}
and I can also make a query like
query FirstPieces {
listTests(filter: {text_pieces: {contains: "FirstPiece"}}) {
items {
name
text_pieces
}
}
}
which again returns:
{
"name": "FirstTest",
"text_pieces": [
"FirstPiece",
"SecondPiece"
]
}
However, I'd also like to be able to use an operator like beginsWith with every element in the text_pieces array and filter through that. So something like
query FirstPieces {
listTests(filter: {text_pieces: {items { beginsWith: "First"}}}) {
items {
name
text_pieces
}
}
}
which would still return
{
"name": "FirstTest",
"text_pieces": [
"FirstPiece",
"SecondPiece"
]
}
Is that supported by Amplify by concatenating the already available filters? Or probably something that would need its own resolver?