amplify-category-api
amplify-category-api copied to clipboard
@index directive with multiple sortKeys is not filtered by second field
Before opening, please confirm:
- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have searched for duplicate or closed issues.
- [X] I have read the guide for submitting bug reports.
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
How did you install the Amplify CLI?
npm install -g @aws-amplify/cli
If applicable, what version of Node.js are you using?
v16.17.0
Amplify CLI Version
10.0.0 & 9.2.1
What operating system are you using?
MacOS 12.6
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual changes made
Amplify Categories
api
Amplify Commands
push
Describe the bug
As an example scenario: I am trying to filter table Order
by Int field updated
and sort by Int field created
. For this I have the index listOrdersByCreated
with two sortKeys ["created", "updated"]
.
enum OrderType {
HARDWARE
SOFTWARE
}
type Order @model @auth(rules: [{ allow: private }]) {
id: ID!
type: OrderType!
@index(name: "byCreated", queryField: "listOrdersByCreated", sortKeyFields: ["created", "updated"])
created: Int!
updated: Int!
}
For filtering I use between
. The created
field is filtered, but the updated
field is ignored:
query MyQuery {
listOrdersByCreated(
type: HARDWARE
createdUpdated: {
between: [
{ created: 0, updated: 0 },
{ created: 2003187334, updated: 2003187334 }
]
}
) {
items {
created
updated
}
}
}
Result (correct):
{
"data": {
"listOrdersByCreated": {
"items": [
{
"created": 1663321326,
"updated": 1664421326
},
{
"created": 1663321333,
"updated": 1664421333
},
{
"created": 1663321339,
"updated": 1664421339
}
]
}
}
}
filter by created:
between: [
{ created: 0, updated: 0 },
{ created: 1, updated: 2003187334 }
]
Result (correct):
{
"data": {
"listOrdersByCreated": {
"items": []
}
}
}
filter by updated:
between: [
{ created: 0, updated: 0 },
{ created: 2003187334, updated: 1 }
]
Result (wrong):
{
"data": {
"listOrdersByCreated": {
"items": [
{
"created": 1663321326,
"updated": 1664421326
},
{
"created": 1663321333,
"updated": 1664421333
},
{
"created": 1663321339,
"updated": 1664421339
}
]
}
}
}
Apparently, the second field is completely ignored.
Expected behavior
I can filter my index by updated
too.
Reproduction steps
- Add api & use schema
- Make call in AppSync
GraphQL schema(s)
enum OrderType {
HARDWARE
SOFTWARE
}
type Order @model @auth(rules: [{ allow: private }]) {
id: ID!
type: OrderType!
@index(name: "byGeo", queryField: "listOrdersByCreated", sortKeyFields: ["created", "updated"])
created: Int!
updated: Int!
}
Log output
# Put your logs below this line
Additional information
No response