Amplify-cli: [request?] `amplify codegen` does not reflect updated schema from local copy

Created on 20 Jul 2020  路  3Comments  路  Source: aws-amplify/amplify-cli

Is your feature request related to a problem? Please describe.

Problem 1: codegen doesnt codegen from local copy

when i update my local schema in /amplify/backend/api/MYAPI/schema.graphql and run amplify codegen, the generated code in src/graphql doesn't update at all.

we are not sure if this is a bug or working as intended. but it's clear that in order to update the generated code i have to amplify push.

Problem 2: CLI gives the impression that codegen is done before push

I have to amplify push before i can codegen the new model:

image

this causes a LONG wait time and completely breaks my flow, for information i already have on my machine.

I ran amplify push 40 minutes 1 hour ago and am still waiting for my updated graphql schema so i can continue working. this is not a sustainable workflow when i'm just changing one little field on my schema.

Repro steps

  1. amplify add api
  2. amplify codegen
  3. change one field in the graphql schema
  4. amplify codegen again
  5. observe that nothing has changed in src/graphql

Describe the solution you'd like

i understand you do this in order to always codegen the right thing. but perhaps offer to codegen based off my local model first, if i accept the risks of mismatch between the model i have on my machine and the model i have in the cloud.

Describe alternatives you've considered

do nothing

code-gen feature-request

Most helpful comment

The main reason for this is that the new schema is not compiled. A temporary solution is to run amplify api gql-compile after changing the schema and then it is all good to run amplify codegen. I will soon create a PR for graphql compiling check when running codegen.

All 3 comments

The main reason for this is that the new schema is not compiled. A temporary solution is to run amplify api gql-compile after changing the schema and then it is all good to run amplify codegen. I will soon create a PR for graphql compiling check when running codegen.

If I run the indicated commands, it still doesn't seem to update the generated code in src/graphql although the compile step does seem to know about the changes - just codegen doesn't do anything as far as I can tell.

Re-opening as we are reconsidering the implementation. As of now the current workaround when making schema changes, you can run amplify api gql-compile && amplify codegen.

Was this page helpful?
0 / 5 - 0 ratings