Amplify-cli: amplify mock failed to start when using @key directives

Created on 18 Oct 2019  路  2Comments  路  Source: aws-amplify/amplify-cli

Describe the bug
Hi there, I am getting the following error when running amplify mock: Failed to start API Mock endpoint ValidationException: The number of attributes in key schema must match the number of attributesdefined in attribute definitions.

To Reproduce

schema.graphql type Customer @model @key(fields: ["id", "updatedAt"]) @key(name: "BySpending", fields: ["id", "totalSpending"]) @key(name: "ByAttendance", fields: ["id", "totalAttendance"]) @auth(rules: [{ allow: owner }, { allow: groups, groups: ["Admin"] }]) { id: ID! ... totalSpending: Int! totalAttendance: Int! ... entries: [Entry] @connection(name: "CustomerEntries") ... owner: ID! createdAt: AWSDateTime updatedAt: AWSDateTime! }

Expected behavior
Create two LSI and start AppSync Mock service.
The schema above should have met the LSI requirement:

Every local secondary index must meet the following conditions:

  • The partition key is the same as that of its base table.
  • The sort key consists of exactly one scalar attribute.
  • The sort key of the base table is projected into the index, where it acts as a non-key attribute.

Screenshots
It seems OK when pushing to cloud
image

Desktop (please complete the following information):

  • OS: macOS Mojave
  • amplify-cli: 3.15
  • node: 10.16.3

Additional context
related #1725 #2059

bug mock

Most helpful comment

I can reproduce this error, too.

All 2 comments

Same error.

I can reproduce this error, too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicksmithr picture nicksmithr  路  3Comments

jeanpaulcozzatti picture jeanpaulcozzatti  路  3Comments

nason picture nason  路  3Comments

rehos picture rehos  路  3Comments

amlcodes picture amlcodes  路  3Comments