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

Can't generate models if schema used identifier function #909

Open
robot-apocalypse opened this issue Nov 15, 2024 · 1 comment
Open

Can't generate models if schema used identifier function #909

robot-apocalypse opened this issue Nov 15, 2024 · 1 comment
Labels
Gen 2 pending-triage Issues that need further discussion to determine transferred Issue has been transferred from another Amplify repository

Comments

@robot-apocalypse
Copy link

robot-apocalypse commented Nov 15, 2024

Environment information

System:
  OS: macOS 15.1
  CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  Memory: 40.66 MB / 32.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 22.6.0 - ~/.nvm/versions/node/v22.6.0/bin/node
  Yarn: undefined - undefined
  npm: 10.8.2 - ~/.nvm/versions/node/v22.6.0/bin/npm
  pnpm: 9.11.0 - ~/.nvm/versions/node/v22.6.0/bin/pnpm
NPM Packages:
  @aws-amplify/auth-construct: Not Found
  @aws-amplify/backend: Not Found
  @aws-amplify/backend-auth: Not Found
  @aws-amplify/backend-cli: 1.4.2
  @aws-amplify/backend-data: Not Found
  @aws-amplify/backend-deployer: 1.1.9
  @aws-amplify/backend-function: Not Found
  @aws-amplify/backend-output-schemas: 1.4.0
  @aws-amplify/backend-output-storage: Not Found
  @aws-amplify/backend-secret: 1.1.5
  @aws-amplify/backend-storage: Not Found
  @aws-amplify/cli-core: 1.2.0
  @aws-amplify/client-config: 1.5.2
  @aws-amplify/deployed-backend-client: 1.4.2
  @aws-amplify/form-generator: 1.0.3
  @aws-amplify/model-generator: 1.0.9
  @aws-amplify/platform-core: 1.2.0
  @aws-amplify/plugin-types: 1.4.0
  @aws-amplify/sandbox: 1.2.5
  @aws-amplify/schema-generator: 1.2.5
  aws-amplify: 6.8.2
  aws-cdk: 2.164.1
  aws-cdk-lib: 2.164.1
  typescript: 5.6.3
AWS environment variables:
  AWS_PAGER =
  AWS_PROFILE = crowder
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables

Describe the bug

It seems like if I specify an identifier on my schema models, then I'm not able to generate graphql-client-code. If I do have an identifier, whether composite or single value, i get the following error when I run the generate command:
TypeError: Cannot read properties of undefined (reading 'primaryKeyInfo')

Reproduction steps

I have a schema model like so:

Crowd: a
    .model({
      createdAt: a.timestamp().required(),
      lastModifiedAt: a.timestamp(),
      userId: a.id().required(),
      user: a.belongsTo('User', 'userId'),
      shopId: a.id().required(),
      shop: a.belongsTo('Shop', 'shopId'),
      offer: a.float(),
      productURL: a.string(),
      productId: a.string().required(),
    })
    .identifier(['userId', 'shopId', 'productId'])
    .authorization((allow) => [allow.publicApiKey()])

The goal is to have a composite identifier made up of userId, shopId and productId, but I have also tried with just e.g shopId and gotten the same result.

The command I run is:
npx ampx generate graphql-client-code --format modelgen --model-target dart --out lib/src/db --stack <stack-name>

@robot-apocalypse robot-apocalypse added the pending-triage Issues that need further discussion to determine label Nov 15, 2024
@robot-apocalypse robot-apocalypse closed this as not planned Won't fix, can't repro, duplicate, stale Nov 16, 2024
@ykethan
Copy link
Member

ykethan commented Nov 18, 2024

Hey,👋 thanks for raising this! I'm going to transfer this over to our codegen repository for better assistance 🙂

@ykethan ykethan transferred this issue from aws-amplify/amplify-backend Nov 18, 2024
@ykethan ykethan added transferred Issue has been transferred from another Amplify repository Gen 2 labels Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gen 2 pending-triage Issues that need further discussion to determine transferred Issue has been transferred from another Amplify repository
Projects
None yet
Development

No branches or pull requests

2 participants