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

--statement-typename-introspection=false Flag Fails to Remove __typename in Generated Types #920

Open
mnai01 opened this issue Dec 29, 2024 · 1 comment
Labels
amplify-codegen Issues on amplify-codegen bug Something isn't working transferred Issue has been transferred from another Amplify repository

Comments

@mnai01
Copy link

mnai01 commented Dec 29, 2024

Environment information

System:
  OS: Windows 10 10.0.19045
  CPU: (8) x64 Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
  Memory: 14.02 GB / 31.95 GB
Binaries:
  Node: 20.11.1 - F:\Program Files\nodejs\node.EXE     
  Yarn: undefined - undefined
  npm: 10.2.4 - F:\Program Files\nodejs\npm.CMD        
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/auth-construct: 1.5.1
  @aws-amplify/backend: 1.11.0
  @aws-amplify/backend-auth: 1.4.2
  @aws-amplify/backend-cli: 1.4.5
  @aws-amplify/backend-data: 1.3.0
  @aws-amplify/backend-deployer: 1.1.12
  @aws-amplify/backend-function: 1.10.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.4
  @aws-amplify/deployed-backend-client: 1.5.0
  @aws-amplify/form-generator: 1.0.3
  @aws-amplify/model-generator: 1.0.11
  @aws-amplify/platform-core: 1.4.0
  @aws-amplify/plugin-types: 1.6.0
  @aws-amplify/sandbox: 1.2.8
  @aws-amplify/schema-generator: 1.2.6
  aws-amplify: 6.10.2
  aws-cdk: 2.173.4
  aws-cdk-lib: 2.172.0
  typescript: 5.7.2
No AWS environment variables
No CDK environment variables

Describe the bug

When running the following command:

npx ampx generate graphql-client-code \
  --out ./src/store/api/generated \
  --format graphql-codegen \
  --statement-typename-introspection=false

the generated TypeScript types still contain __typename fields, even though --statement-typename-introspection=false is supposed to prevent them. Meanwhile, the actual client.models.* responses from Amplify do not include these __typename properties, leading to mismatched shapes in the generated types vs. the returned data.

Reproduction steps

  1. Install or update Amplify / ampx:
    npm install -g ampx
  2. Run the codegen command in your project:
    npx ampx generate graphql-client-code \
      --out ./src/store/api/generated \
      --format graphql-codegen \
      --statement-typename-introspection=false
  3. Observe that the generated files in ./src/store/api/generated still include __typename fields.
  4. Compare the returned objects from client.models.* (which do not include __typename) to the generated types (which do include it) and note the mismatch.
@mnai01 mnai01 added the pending-triage Issues that need further discussion to determine label Dec 29, 2024
@mnai01 mnai01 changed the title **--statement-typename-introspection=false Flag Fails to Remove __typename in Generated Types** --statement-typename-introspection=false Flag Fails to Remove __typename` in Generated Types Dec 29, 2024
@mnai01 mnai01 changed the title --statement-typename-introspection=false Flag Fails to Remove __typename` in Generated Types --statement-typename-introspection=false Flag Fails to Remove __typename in Generated Types Dec 29, 2024
@ykethan
Copy link
Member

ykethan commented Dec 30, 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 Dec 30, 2024
@ykethan ykethan added the transferred Issue has been transferred from another Amplify repository label Dec 30, 2024
@AnilMaktala AnilMaktala added bug Something isn't working amplify-codegen Issues on amplify-codegen and removed pending-triage Issues that need further discussion to determine labels Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
amplify-codegen Issues on amplify-codegen bug Something isn't working transferred Issue has been transferred from another Amplify repository
Projects
None yet
Development

No branches or pull requests

3 participants