Open JGamboa opened 2 weeks ago
Hi @JGamboa, Thanks for raising this. This issue is related to #2636. Please subscribe to #2636 for future updates.
Hi @JGamboa
The error seems to be complaining about implicit fields that are automatically added by the graphql transformer. They are being marked as required on the schema.
In the meantime, can you try generating your graphql statements using this command instead?
npx ampx generate graphql-client-code --statement-max-depth=1 --out=ui-components/graphql
I was able to reproduce the errors related to the relational fields and mitigated it with the command above, allowing me to create records without errors with the generated forms.
code
"use client";
import { Authenticator } from "@aws-amplify/ui-react";
import "@aws-amplify/ui-react/styles.css";
import CustomerCreateForm from "@/ui-components/CustomerCreateForm";
const App = () => {
return (
<Authenticator>
{({ user, signOut }) => {
return (
<>
<h1>Hello {user?.username}</h1>
<h1>Protected content!</h1>
<CustomerCreateForm />
</>
);
}}
</Authenticator>
);
};
export default App;
before
after
Hi @JGamboa
The error seems to be complaining about implicit fields that are automatically added by the graphql transformer. They are being marked as required on the schema.
In the meantime, can you try generating your graphql statements using this command instead?
npx ampx generate graphql-client-code --statement-max-depth=1 --out=ui-components/graphql
sorry just getting back home thats why didnt answer earlier. Ill try, but either way, i already create almost all the app again using queries =/ will have in mind for new formularies :D
Hey @JGamboa, Could you please provide the library versions you were using when the mutation code looked like this?
this is the one created by the old one
export const createCustomer = /* GraphQL */ mutation CreateCustomer( $condition: ModelCustomerConditionInput $input: CreateCustomerInput! ) { createCustomer(condition: $condition, input: $input) { createdAt email fullName id owner phone updatedAt __typename } };
@AnilMaktala sorry i cant, after this "upgrade" amplify team make, i lost 80% of functionalities, so i made the rework, i dont have any chance to know what version i was using. But i can say it was the previous version, im very sorry. :(
Environment information
Data packages
Description
After the latest upgrade of npm packages of amplify my application broke.
We have this model
We are using only the forms generated by amplify with generate forms. After the update, when regenerating forms , mutations etc with the command we started getting problems on update and create like this
Basically we have the billing information that is abelogns to customer and a has one from customer, but it can be set later, now if we try to update or create customer with the amplify form we get that errors.
I know this is a security improvement but i think there is a lot of dev and companies having this problem and rolling back the cli is not an option at the moment (Security concerns) Is it possible to add a flag on the command so we can choose how the forms are generated?
This is the way how amplify is creating the graphql client
Maybe we can choose to genereate that from default, or a flag to choose to use the client schema query, because if. you use the schema query client you dont have any problem, but everytime we regenerate the forms everythings goes back to the mutation
this is the mutation created by the new cli
export const createCustomer = / GraphQL /
mutation CreateCustomer( $condition: ModelCustomerConditionInput $input: CreateCustomerInput! ) { createCustomer(condition: $condition, input: $input) { billingInformation { address city companyName createdAt customerId id identityCard municipality owner updatedAt __typename } createdAt email fullName id owner phone updatedAt __typename } }
;this is the one created by the old one
export const createCustomer = / GraphQL /
mutation CreateCustomer( $condition: ModelCustomerConditionInput $input: CreateCustomerInput! ) { createCustomer(condition: $condition, input: $input) { createdAt email fullName id owner phone updatedAt __typename } }
;and pretty sure thats is what generating all this problems