amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

Amplify Mock one-to-many Error DynamoDB:ValidationException

Open acdani opened this issue 7 years ago • 4 comments

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

  1. 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 }

  1. amplify mock, it will ask to amplify push also
  2. Open graphql sandox http://IP:20002/
  3. Mutation to create Wallet item
mutation NewWallet {
  __typename
  createWallet(input: {}) {
    id
  }
}
  1. Create new card and link to wallet id from last step
mutation NewCardToWallet {
  __typename
  createCard(input: {cardWalletId: "bb774ba6-d93b-47c6-b39c-5b4e8c7015db"}) {
    id
  }
}
  1. 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.

acdani avatar Nov 22 '19 22:11 acdani

did you ever get any help with this? Im running into the same thing

nikhilbatta avatar Feb 06 '20 18:02 nikhilbatta

same here

clovisrodriguez avatar Feb 13 '20 15:02 clovisrodriguez

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

yuth avatar Feb 22 '20 00:02 yuth

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.

github-actions[bot] avatar May 26 '21 15:05 github-actions[bot]