- Newest
- Most votes
- Most comments
The error you're encountering indicates a mismatch between your schema definition and the GraphQL mutation you're trying to execute. The error message states that your mutation is missing required fields 'ReferenceID' and 'TotalGrossAmount', but these fields aren't defined in your schema.
There are a few potential issues to investigate:
-
Schema vs. Deployed Schema Mismatch: The schema that's currently deployed might be different from the one you've shared. It's possible that an older version of your schema (which included ReferenceID and TotalGrossAmount as required fields) is still active.
-
Field Definition Issue: In your schema, you've defined
InvoiceDetailsItemin your mutation, but this field doesn't appear in yourSupplierInvoiceInputtype definition. Instead, you have definedInvoiceDocument. -
Type Generation: If you've recently updated your schema, you might need to regenerate your types to ensure everything is in sync.
To resolve this issue:
-
Make sure your schema definition matches what you want to use in your mutation. If you need ReferenceID and TotalGrossAmount, add them to your SupplierInvoiceInput type with the required() modifier.
-
Deploy your updated schema to ensure the backend is using the latest version.
-
If you've made changes to your schema, run the appropriate command to regenerate types:
npx ampx generate types --lang typescript
(Note that the exact command might vary depending on your setup)
-
Check that your tsconfig.json includes the Amplify-generated types by ensuring it has an include path for "amplify/**/*.ts".
-
Restart your TypeScript language server in your IDE to ensure it picks up the latest type definitions.
By aligning your schema definition with your mutation and ensuring your deployment is up to date, you should be able to resolve this validation error.
Sources
Amplify Gen2 Types | AWS re:Post
Add fields to data model - AWS Amplify Gen 2 Documentation
Relevant content
asked 2 years ago
- AWS OFFICIALUpdated 4 years ago
