Amplify-cli: Unable to search on enum field with @searchable

Created on 23 Jan 2020  路  19Comments  路  Source: aws-amplify/amplify-cli

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the
Amplify Console GitHub Issue Tracker

Describe the bug
It is not possible to search in an enum field, the transform does not construct the search query with that field.

Amplify CLI Version
4.12.0

To Reproduce
Make a @model and @searchable type, add a enum field type, and build.

Expected behavior
The enum type field were included

enhancement graphql-transformer

Most helpful comment

+1 - facing the same issue and would expect enum types to behave like string input types when it comes to sorting/filtering

All 19 comments

Any updates on this?

+1

+1

+1 - enterprise blocker, any workarounds known?

+1

+1

Hi all, we understand this is a pain-point and will prioritize accordingly but we can't commit to a timeline for the fix at this point.

In the meantime, the workaround is to modify the generated search query to include the enum in your schema.

@edwardfoyle We don't want to change generated code files, so we copyied the Searchable FilterInput to our schema.graphql:

  1. Copy the generated input called SearchableFooBarFilterInput from build/schema.graphql to your schema.graphql. (Where FooBar is the name of your model.)
  2. Copy all *FilterInput dependencies of the above input as well.
  3. Add myEnum: SearchableStringFilterInput to the SearchableFooBarFilterInput in schema.graphql.
  4. amplify push

This unblocks us, but obviously the workaround is not great in the long term, so I appreciate that you're prioritizing a fix in Amplify.

On our end, we worked around this issue from the application layer by creating a proxy string field to replicate the enum field value.

Order @model @searchable {
  paymentStatus: OrderPaymentStatusEnum!
  paymentState: String! # Proxy for paymentStatus to enable filtering on searchable

I share the same sentiments with @mmiermans on this issue.

This unblocks us, but obviously the workaround is not great in the long term, so I appreciate that you're prioritizing a fix in Amplify.

Thanks!

+1 - facing the same issue and would expect enum types to behave like string input types when it comes to sorting/filtering

  • 1

+1
I think I will go with the Proxy solution but it's a pain.

+1

+1 please fix it team :-)

+1

+1

+1

Hey @edwardfoyle.
Do you have good news to share with us about this missing feature?

+1

Was this page helpful?
0 / 5 - 0 ratings