-
Notifications
You must be signed in to change notification settings - Fork 63
ampify codegen model
filters out connection fields
#214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@TheDutchCoder could you share the complete schema and the use case you try to achieve to be able to help you better? From this partial information it is harder to see what you try to do, beside that modelgen generated code is not "optimal", but I suspect that maybe the model could be change if we know what are the goals. |
I can't really give the whole schema, it's quite big, but I'll give you all related things for the one model: Model type UserInvite
@model(subscriptions: null)
@key(name: "invitationsByBusiness", fields: ["businessID","id"], queryField: "invitationsByBusiness")
@key(name: "invitationsByEmail", fields: ["email","id"], queryField: "invitationsByEmail")
{
id: ID!
businessID: ID!
email: String!
role: UserRole!
business: Business @connection(fields: ["businessID"])
status: UserInviteStatus!
createdAt: AWSDateTime!
} Subscriptions type Subscription {
onCreateUserInvite(businessID: ID): UserInvite
@aws_subscribe(mutations: ["createUserInvite"])
onUpdateUserInvite(businessID: ID): UserInvite
@aws_subscribe(mutations: ["updateUserInvite"])
onDeleteUserInvite(businessID: ID): UserInvite
@aws_subscribe(mutations: ["deleteUserInvite"])
onCreateUserInviteEmail(email: String): UserInvite
@aws_subscribe(mutations: ["createUserInvite"])
onUpdateUserInviteEmail(email: String): UserInvite
@aws_subscribe(mutations: ["updateUserInvite"])
onDeleteUserInviteEmail(email: String): UserInvite
@aws_subscribe(mutations: ["deleteUserInvite"])
} Enum enum UserInviteStatus {
pending
accepted
rejected
} Query export const getUserInvite = /* GraphQL */ `
query GetUserInvite($id: ID!) {
getUserInvite(id: $id) {
id
businessID
email
role
business {
id
name
slug
owner
users {
items {
id
businessID
name
initials
email
role
active
business {
id
name
slug
owner
createdAt
updatedAt
}
createdAt
updatedAt
}
nextToken
}
createdAt
updatedAt
}
status
createdAt
updatedAt
}
}
`; Goal: to get Is that enough to go on? |
We should verify if this is an issue in the v2 transformer version as well. |
Describe the bug
When you have a connection field in your schema, like this:
The generated models do not include the
customerID
property and instead nest it undercustomer.business.id
because it maps business to be of typeBusiness
.This is technically not "wrong", but the result still very much includes
customerID
when queries and now the models don't line up anymore. Reading the result ascustomer.business.id
probably works, but it's not the most efficient.Amplify CLI Version
4.41.1
To Reproduce
Create a schema with a connection field.
Run codegen for models.
See the property is missing.
Expected behavior
Property to still be included.
Screenshots

Missing property in the models.
TS error when using the model

Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: