Describe the bug
amplify mock
can't find an index created by @key
.
I get the following error:
{
message: 'The table does not have the specified index: NotificationsByUserName',
code: 'ValidationException',
time: 2019-09-05T19:05:41.648Z,
requestId: '9e655eba-e5c1-4b69-8d63-4dae49c210ae',
statusCode: 400,
retryable: false,
retryDelay: 12.841308304961863
}
Here's my key:
@key(
name: "NotificationsByUserName"
fields: ["userName"]
queryField: "notificationsByUserName"
)
If I change the query field to match the casing (capital n) and re-run amplify mock
it works.
To Reproduce
Steps to reproduce the behavior:
amplify mock
Expected behavior
Mock should distinguish between the queryField value and the name value of a key.
@aireater did you update the schema with @key
directive after running amplify mock
?
@yuth when i first ran mock i was using a custom resolver (before @key
was available). I since deleted that custom resource (which was causing a missing index error in mock) and created the key to maintain the same functionality on the client.
@aireater Mock does not re-create/update the table once table gets created. We are going to fix this but for now you could delete <project-root>/amplfiy/mock-data/
if you don't mind loosing your test data
@yuth thanks, will do.
Re-opening issue as this is a bug in Mock implementation. Thanks for reporting
@yuth Have you started on this issue? I'm looking to fix this.
@mwarger Are you close with your PR for this fix?
Not really. I would need to get back into this. I have had to work on other things.
@yuth I encountered this today while working on a proof of concept. Updated the schema with @key
directive after running mock.
I expected this may be an issue. Ran amplify remove api
&& amplify add api
hoping that it would fix the issue.
It didn't work, because <project-root>/ amplify/mock-data/dynamodb/fake_us-fake-1.db
is not deleted when amplify remove api
is ran.
Should the amplify remove api
be updated to remove the mock data as a default?
@BrittonWinterrose deleting the mock-data directory works for me.
The change is released in Amplify CLI 4.18.1
Most helpful comment
@BrittonWinterrose deleting the mock-data directory works for me.