amplify-category-api
                                
                                 amplify-category-api copied to clipboard
                                
                                    amplify-category-api copied to clipboard
                            
                            
                            
                        Records with AWSDate using timezone not being returned in searchable queries when using @searchable directives
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
If applicable, what version of Node.js are you using?
17
Amplify CLI Version
10.0.0
What operating system are you using?
Mac
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual changes made
Amplify Categories
Not applicable
Amplify Commands
Not applicable
Describe the bug
Whenever there is a model using the @searchable directive with an AWSDate field with a timezone (e.g "2022-10-13Z" or "2022-10-13+05:30") and a searchModelName query is used using the date field as a filter or sorting field, the query doesn't show up the results with a timezone.
Expected behavior
All of the results to show up, including the ones with a timezone.
Reproduction steps
- Create a transaction without a timezone
mutation createTransaction {
  createTransaction(input: {name: "Lorem ipsum dolor sit amet",
          transactionDate: "2010-09-28",
          transactionTotalAmount: 5.1}) {
    name
    transactionDate
    transactionTotalAmount
    id
    createdAt
    updatedAt
  }
}
- Create a transaction with a timezone
mutation createTransaction {
  createTransaction(input: {name: "Lorem ipsum dolor sit amet",
          transactionDate: "2010-09-28Z",
          transactionTotalAmount: 5.1}) {
    name
    transactionDate
    transactionTotalAmount
    id
    createdAt
    updatedAt
  }
}
- Filter by any field using transactionDate as sorting field
query filterAndSort {
  searchTransactions(filter: {transactionTotalAmount: {eq: 5.1}},
  sort: {direction: desc, field: transactionDate}, limit: 10) {
    total
    items {
      id
      transactionDate
      createdAt
      transactionTotalAmount
    }
  }
}
Only the transaction without a timezone appears as a result.
GraphQL schema(s)
type Transaction @model @searchable {
  id: ID!
  name: String!
  transactionDate: AWSDate
  transactionTotalAmount: Float
}ytj
Log output
# Put your logs below this line
Additional information
A possible workaround is to use AWSDatetime or String instead as the date data type. Also, I would suspect this is due to OpenSearch data types, as dates in the format YYYY-MM-DD are not supported with a timezone in OpenSearch.