generateClient observeQuery with filters does not seem to work if schema has composite identifier #13965
Open
3 tasks done
Labels
GraphQL
Related to GraphQL API issues
pending-maintainer-response
Issue is pending a response from the Amplify team.
to-be-reproduced
Used in order for Amplify to reproduce said issue
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
GraphQL API
Amplify Version
v6
Amplify Categories
api
Backend
None
Environment information
Describe the bug
When using
observeQuery
, E.g:const client = generateClient<Schema>()
thenclient.models.DeviceMeasures.observeQuery
- if you supply afilter
that uses those columns, you get a runtime errorThe variables input contains a field that is not defined for input object type 'ModelSubscriptionDeviceMeasuresFilterInput'
. It seems there is an issue with the generated graphQL for the schema.When using filters for any tables that just use the default in-built ID, this does not happen, the filters work fine.
Expected behavior
Data should be filtered correctly and no error shown.
Reproduction steps
In your resource.ts, set up a schema that has an identifier with a composite key (E.g. two string columns):
We can see the "correct" looking graphQL is generated:
Code Snippet
When you create an observeQuery that tries to use the columns in the identifier:
It will give the error
The variables input contains a field that is not defined for input object type 'ModelSubscriptionDeviceMeasuresFilterInput'
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
As a workaround, I can allow it to retieve all items by removing the filter, then filter in the UI, but this will not be efficient at scale as I may have many records coming back that I just ignore:
The text was updated successfully, but these errors were encountered: