Amplify-cli: CLI no longer appears to generate API.ts after schema change

Created on 12 Sep 2019  路  6Comments  路  Source: aws-amplify/amplify-cli

Describe the bug
The amplify cli no longer appears to generate an updated API.ts after a schema change. I first noticed this while running mock and not seeing my expected types reflected. This appears to be independent of mock though, since just running amplify codegen or amplify codegen types does not resolve it.

To Reproduce
Steps to reproduce the behavior:

  1. I used the generated three model example with blog, post, comment
  2. Run codegen using typescript and default configuration
  3. Queries, mutations, and everything else generates, but API.ts does not update
  4. Deleting API.ts and running again, does not generate a file (unless you count https://github.com/aws-amplify/amplify-cli/issues/2002 - which is blank)

Expected behavior
API.ts should be there - this appears to be a regression in the tool

Please prioritize this, if possible - this really hinders progress. Thank you.

amplify -v
3.2.0

bug code-gen pending-release pending-response

Most helpful comment

seeing something similar in v4.13.4 ...

Seeing something similar as well. API.ts is empty however it still generates queries.

projects:
  covidmars:
    schemaPath: packages/service/schema.json
    includes:
      - packages/api/service/**/*.ts
    excludes:
      - ./amplify/**
    extensions:
      amplify:
        codeGenTarget: typescript
        generatedFileName: packages/service/API.ts
        docsFilePath: packages/service/graphql
extensions:
  amplify:
    version: 3

All 6 comments

@mwarger could you share your .graphqlconfig.yml file with sensitive information redacted

ahh, I see what you're referring to.

projects:
  tshelper:
    schemaPath: amplify/backend/api/tshelper/build/schema.graphql
    includes:
      - src\graphql\**\*.ts
    excludes:
      - ./amplify/**
    extensions:
      amplify:
        codeGenTarget: typescript
        generatedFileName: src\API.ts
        docsFilePath: src\graphql
        maxDepth: 2

I fixed it by changing the slashes to be / instead, and it works. This is related to #2002, I bet.

We have fixed this issue https://github.com/aws-amplify/amplify-cli/pull/2212 which is pending release.

We released a new version of the CLI - v3.8.0 with a fix for this.

seeing something similar in v4.13.4.

Here's my .graphqlconfig.yml for reference:

projects:
  myproject:
    schemaPath: products/web/src/graphql/schema.json
    includes:
      - products/web/src/graphql/**/*.js
    excludes:
      - amplify/**
    extensions:
      amplify:
        codeGenTarget: typescript
        generatedFileName: products/web/src/API.ts
        docsFilePath: products/web/src/graphql
        graphQLApiId: rzktsf3bznh5xpe362x7xoxbeu
extensions:
  amplify:
    version: 3

seeing something similar in v4.13.4 ...

Seeing something similar as well. API.ts is empty however it still generates queries.

projects:
  covidmars:
    schemaPath: packages/service/schema.json
    includes:
      - packages/api/service/**/*.ts
    excludes:
      - ./amplify/**
    extensions:
      amplify:
        codeGenTarget: typescript
        generatedFileName: packages/service/API.ts
        docsFilePath: packages/service/graphql
extensions:
  amplify:
    version: 3
Was this page helpful?
0 / 5 - 0 ratings