Open
Description
Description
If making a field as sortKey in secondaryIndex and making the field optional, we are not able to submit a create request without specifying the value of this field.
Categories
- Analytics
- API (REST)
- API (GraphQL)
- Auth
- Authenticator
- DataStore
- Notifications (Push)
- Storage
Steps to Reproduce
- For any model, add secondary index like this:
Message: a
.model({
roomId: a.id().required(),
room: a.belongsTo('Room', 'roomId'),
createdAt: a.string(),
}).secondaryIndexes(index => [index('roomId').sortKeys(['createdAt']).queryField('listByDate')])
- Then submit a request to create a message (without specify
createAt
value since it should be created by backend):
final newMessage = Message(room: room);
final request = ModelMutations.create(newMessage);
final response = await Amplify.API.mutate(request: request).response;
- Then it will show error
One or more parameter values were invalid: Type mismatch for Index Key createdAt Expected
, I noticed this is becausecreateAt
has a value null in request.variables['input'] instead of just ignoring it
What I want to do is just to sort messages by createAt date, this is one of the bug I found during the attempts. Not sure if it is the correct way.
Screenshots
No response
Platforms
- iOS
- Android
- Web
- macOS
- Windows
- Linux
Flutter Version
3.19.3
Amplify Flutter Version
2.0.0
Deployment Method
Amplify CLI
Schema
No response