You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using observeQuery, E.g: const client = generateClient<Schema>() then client.models.DeviceMeasures.observeQuery - if you supply a filter that uses those columns, you get a runtime error The 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):
It will give the error The variables input contains a field that is not defined for input object type 'ModelSubscriptionDeviceMeasuresFilterInput'
Log output
//This is the output from my own logging code as above:
NOTIFY ERROR Error in DeviceMeasures subscription - {"type":"onUpdate","error":{"errors":[{"message":"Connection failed: {\"errors\":[{\"message\":\"The variables input contains a field that is not defined for input object type 'ModelSubscriptionDeviceMeasuresFilterInput' \"}]}"}]}}
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:
useEffect(() => {
const subscription = client.models.DeviceMeasures.observeQuery({
/* we will remove the filter as there is a bug preventing it working - filter after
filter: {
and: [
{ tenantId: { eq: device.tenantId } },
{ name: { eq: device.name } }
]
}
*/
}).subscribe({
next: ({ items }) => {
//once bug is fixed we can put this back: setDeviceMeasures(items[0] || null);
//for now, filter here
setDeviceMeasures(items.filter(item => item.tenantId === device.tenantId && item.name === device.name)[0] || null);
setLoading(false);
},
error: (err) => {
notifyError('Error in DeviceMeasures subscription', err);
setError(
'Failed to fetch or update device data. Please try again later.'
);
setLoading(false);
},
});
return () => subscription.unsubscribe();
}, [device.tenantId, device.name]);
The text was updated successfully, but these errors were encountered:
Hi @nootn 👋 thanks for raising this issue. apologies for the delay.
I was able to consistently reproduce the error when attempting to subscribe to changes on the DeviceMeasures model with observeQuery. I've labeled this issue as a bug for the team to investigate further. we will report back with any findings.
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: