Skip to content
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

Critical Bug: Missing teamId Field in amplify-flutter Model Causes GraphQL Mutation Errors #923

Open
fct-devops opened this issue Jan 13, 2025 · 5 comments
Assignees
Labels
bug Something isn't working Dart Target language: Dart

Comments

@fct-devops
Copy link

fct-devops commented Jan 13, 2025

Environment information

System:
  OS: macOS 14.4.1
  CPU: (8) arm64 Apple M1
  Memory: 251.17 MB / 16.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 23.6.0 - /opt/homebrew/bin/node
  Yarn: undefined - undefined
  npm: 10.9.2 - /opt/homebrew/bin/npm
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/auth-construct: 1.5.1
  @aws-amplify/backend: 1.13.0
  @aws-amplify/backend-auth: 1.4.2
  @aws-amplify/backend-cli: 1.4.6
  @aws-amplify/backend-data: 1.4.0
  @aws-amplify/backend-deployer: 1.1.13
  @aws-amplify/backend-function: 1.12.0
  @aws-amplify/backend-output-schemas: 1.4.0
  @aws-amplify/backend-output-storage: 1.1.4
  @aws-amplify/backend-secret: 1.1.5
  @aws-amplify/backend-storage: 1.2.4
  @aws-amplify/cli-core: 1.2.1
  @aws-amplify/client-config: 1.5.5
  @aws-amplify/deployed-backend-client: 1.5.0
  @aws-amplify/form-generator: 1.0.3
  @aws-amplify/model-generator: 1.0.12
  @aws-amplify/platform-core: 1.5.1
  @aws-amplify/plugin-types: 1.7.0
  @aws-amplify/sandbox: 1.2.9
  @aws-amplify/schema-generator: 1.2.6
  aws-amplify: 6.12.0
  aws-cdk: 2.175.1
  aws-cdk-lib: 2.175.1
  typescript: 5.7.3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!                                                                                                                      !!
!!  This software has not been tested with node v23.6.0.                                                                !!
!!  Should you encounter odd runtime issues, please try using one of the supported release before filing a bug report.  !!
!!                                                                                                                      !!
!!  This software is currently running on node v23.6.0.                                                                 !!
!!  As of the current release of this software, supported node releases are:                                            !!
!!  - ^22.0.0 (Planned end-of-life: 2027-04-30)                                                                         !!
!!  - ^20.0.0 (Planned end-of-life: 2026-04-30)                                                                         !!
!!  - ^18.0.0 (Planned end-of-life: 2025-04-30)                                                                         !!
!!                                                                                                                      !!
!!  This warning can be silenced by setting the JSII_SILENCE_WARNING_UNTESTED_NODE_VERSION environment variable.        !!
!!                                                                                                                      !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
No AWS environment variables
No CDK environment variables

Codegen packages

[email protected] /Users/xxx/test
├─┬ @aws-amplify/[email protected]
│ └─┬ @aws-amplify/[email protected]
│   └── @aws-amplify/[email protected]
└─┬ @aws-amplify/[email protected]
  └─┬ @aws-amplify/[email protected]
    └── @aws-amplify/[email protected] deduped

Description

Bug Description:
The amplify-flutter data modeling for Has Many relationships appears to have a discrepancy between the official documentation and the generated model, leading to runtime errors when creating a Member. Below are the steps to reproduce the issue, the observed behavior, and the associated error details.

1. Steps to Reproduce:

Follow the Amplify Flutter tutorial on relationships.
Generate the models for a Member with a Has Many relationship to Team.
Observe the generated Member model:
Expected: teamId field should be present (per the documentation).
Actual: Only a team field is generated.
Attempt to create a Member instance by providing a Team instance to initialize Member.
Send the createMember GraphQL mutation request.

// resource.ts
image

// flutter code
image

2. Observed Behavior:

  • The mutation request fails, and the server responds with errors.
  • The request document includes the Team model description, but the input only contains teamId.
  • The member had been saved to the DB
  • Error messages:
Cannot return null for non-nullable type: 'ID' within parent 'Team' (/createMember/team/id)
Cannot return null for non-nullable type: 'String' within parent 'Team' (/createMember/team/mantra)
Cannot return null for non-nullable type: 'AWSDateTime' within parent 'Team' (/createMember/team/createdAt)

3. Expected Behavior:
The Member model should include a teamId field as per the tutorial, allowing Member to be initialized with teamId directly. The mutation request should succeed without including unnecessary Team model details.

4. Error Logs:
image

@fct-devops fct-devops added the pending-triage Issues that need further discussion to determine label Jan 13, 2025
@fct-devops
Copy link
Author

could anyone help? I think this is a very basic feature. Why there's such a bug.

@fct-devops
Copy link
Author

fct-devops commented Jan 15, 2025

Another issue is that it cannot to invoke the method when customize secondary indexes. It didn't generate a code named "listCustomerByAccountRepresentativeId" in dart code, but I found it in the amplify console AI playground.

flow the guide: https://docs.amplify.aws/flutter/build-a-backend/data/data-modeling/secondary-index/

Image

@AnilMaktala AnilMaktala self-assigned this Jan 15, 2025
@AnilMaktala
Copy link
Member

Hey @fct-devops, Thanks for raising this. I have a follow-up question: Could you clarify how you generated the models?

@AnilMaktala AnilMaktala added question Further information is requested pending-community-response Issue is pending a response from the author or community. labels Jan 16, 2025
@fct-devops
Copy link
Author

Hey @fct-devops, Thanks for raising this. I have a follow-up question: Could you clarify how you generated the models?

Thanks for your response. I run the follow cmd to generate:
1、npx ampx generate outputs --branch dev --app-id xxx --format dart --out-dir ./
2、npx ampx generate graphql-client-code --branch dev --app-id xxx --format modelgen --model-target dart --out ../models

@palpatim palpatim added pending-maintainer-response Issue is pending a response from the Amplify team. and removed pending-community-response Issue is pending a response from the author or community. labels Jan 17, 2025
@AnilMaktala
Copy link
Member

Hey @fct-devops, Thank you for providing the additional details. We were able to reproduce the issue using the instructions for Dart models. As a result, we are marking this as a bug for the team to evaluate further.

Image

@AnilMaktala AnilMaktala added bug Something isn't working Dart Target language: Dart and removed question Further information is requested pending-maintainer-response Issue is pending a response from the Amplify team. pending-triage Issues that need further discussion to determine labels Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Dart Target language: Dart
Projects
None yet
Development

No branches or pull requests

3 participants