Amplify Mock one-to-many Error DynamoDB:ValidationException
Describe the bug
When doing a query to return all many of one on the Amplify Mock Graphql sandbox, it's failing with DynamoDB:ValidationException
{
"data": {
"__typename": "Query",
"getWallet": {
"id": "bb774ba6-d93b-47c6-b39c-5b4e8c7015db",
"cards": null
}
},
"errors": [
{
**"errorType": "DynamoDB:ValidationException"**
}
]
}
Amplify CLI Version 3.16.0
To Reproduce
- amplify add api type: graphql GraphQL Transform schema:
type Card @model{
id: ID!
wallet: Wallet @connection(name: "WalletCards")
}
type Wallet @model{
id: ID!
cards: [Card] @connection(name: "WalletCards")
}
Also this is in the log:
Error while executing Local DynamoDB
{
"version": "2017-02-28",
"operation": "Query",
"query": {
"expression": "#connectionAttribute = :connectionAttribute",
"expressionNames": {
"#connectionAttribute": "cardWalletId"
},
"expressionValues": {
":connectionAttribute": {
"S": "bb774ba6-d93b-47c6-b39c-5b4e8c7015db"
}
}
},
"scanIndexForward": true,
"filter": null,
"limit": 10,
"nextToken": null,
"index": "gsi-WalletCards"
}
message:
'The table does not have the specified index: gsi-WalletCards',
code: 'ValidationException',
time: 2019-11-22T22:25:50.941Z,
requestId: 'd6309c40-ff94-425c-9661-91a5a0bc0e9e',
statusCode: 400,
retryable: false,
retryDelay: 12.511334786355665 }
- amplify mock, it will ask to amplify push also
- Open graphql sandox http://IP:20002/
- Mutation to create Wallet item
mutation NewWallet {
__typename
createWallet(input: {}) {
id
}
}
- Create new card and link to wallet id from last step
mutation NewCardToWallet {
__typename
createCard(input: {cardWalletId: "bb774ba6-d93b-47c6-b39c-5b4e8c7015db"}) {
id
}
}
- Query wallet and try to get cards
query ShowCardsInWallet {
__typename
getWallet(id: "bb774ba6-d93b-47c6-b39c-5b4e8c7015db") {
id
cards {
items {
id
}
}
}
}
Expected behavior I expect to get an array of all the cards associated with the wallet.
Desktop (please complete the following information): Windows 10 Node: v10.16.3
Additional context Show stopper, this is such a KEY feature! Your help will be very much appreciated.
did you ever get any help with this? Im running into the same thing
same here
this issue is same as https://github.com/aws-amplify/amplify-cli/issues/2210. This is happening as mock does not update the table when new indices are added. The workaround is deleting <project-root>/amplify/mock-data
I am closing this as duplicate of #2210
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.