AWS Datastore - Amplify codegen models creates always an id even when the schema does not contains thats
See original GitHub issueIk have a schema with these models, so without an ID field:
type User
@model
@key(fields: ["horecaID", "userID"])
@auth(
rules: [
{ allow: groups, groups: ["owner", "supervisor"] }
{ allow: owner, ownerField: "owner", identityClaim: "custom:horeca" }
]
) {
horecaID: ID!
userID: ID!
owner: ID!
name: String!
lastDateLogin: String
group: Group
}
type HorecaCategoryItems
@model
@auth(
rules: [
{ allow: owner, ownerField: "owner", identityClaim: "custom:horeca" }
{ allow: groups, groups: ["owner", "supervisor"] }
{ allow: public, provider: iam, operations: [read] }
{ allow: groups, groups: ["servant", "kitchen"], operations: [read] }
]
) {
horecaID: ID!
category: [Category]!
owner: ID!
}
when I run amplify codegen models and look into index.d.ts into the model dir I have these items with a readonly ID.
export declare class HorecaCategoryItems {
readonly id: string;
readonly horecaID: string;
readonly category: Category[] | keyof typeof Category;
readonly owner: string;
constructor(init: ModelInit<HorecaCategoryItems>);
static copyOf(source: HorecaCategoryItems, mutator: (draft: MutableModel<HorecaCategoryItems>) => MutableModel<HorecaCategoryItems> | void): HorecaCategoryItems;
}
export declare class User {
readonly id: string;
readonly horecaID: string;
readonly userID: string;
readonly owner: string;
readonly name: string;
readonly lastDateLogin?: string;
readonly group?: Group | keyof typeof Group;
constructor(init: ModelInit<User>);
static copyOf(source: User, mutator: (draft: MutableModel<User>) => MutableModel<User> | void): User;
}
Then you get these type of errors:
Sync error, Connection failed: {"errors":[{"message":"Validation error of type FieldUndefined: Field 'id' in type 'User' is undefined @ 'onDeleteUser/id'"}]}
That is correct because I don’t have the ID field in my schema and so not in Dynamodb
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
DataStore - Getting started - Swift - AWS Amplify Docs
The first step to create an app backed by a persistent datastore is to define a schema. DataStore uses GraphQL schema files as...
Read more >Amplify DataStore: Use Cases and Implementation
The first step to create an application backed by a persistent datastore is to define a schema. DataStore uses GraphQL schema files as...
Read more >AWS Amplify For Flutter Part 2: Amplify DataStore
DataStore creates platform-specific model classes using the Amplify CLI command: amplify codegen models . This command starts with the GraphQL ...
Read more >Creating offline web apps with AWS Amplify DataStore
We won't use GraphQL directly but via the DataStore, and we already generated models for it in the last step. Only 4 CLI...
Read more >AWS-Amplify/Lobby - Gitter
I can't find much online, and it's only a single lambda function that's ... I have a problem with 'amplify codegen models', it's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This one you mean?
Nothing changed. Fyi: userID is now missing, but I am using now ID as the user id.
So it seems like that this is giving issues.
@manueliglesias has my project and code.
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 or Discussions for those types of questions.