Skip to content

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

@fct-devops

Description

@fct-devops

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

Metadata

Metadata

Assignees

Labels

DartTarget language: DartbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions