Giter VIP home page Giter VIP logo

Comments (19)

AaronZyLee avatar AaronZyLee commented on August 17, 2024 10

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.

from amplify-codegen.

SwaySway avatar SwaySway commented on August 17, 2024 7

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.

from amplify-codegen.

isaac-rosterlab avatar isaac-rosterlab commented on August 17, 2024 6

Why in the name of all that is holy, do I need to use amplify api gql-compile && amplify codegen instead of just amplify codegen ffs

To take it one step further, why not: "amplify api gql-compile && amplify codegen && amplify codegen models" instead of just "amplify codegen". Also, this workaround should probably be entered in the docs somewhere.

from amplify-codegen.

nubpro avatar nubpro commented on August 17, 2024 2

A little update:
I deleted my .graphqlconfig.yml and did amplify codegen add, it generated a new .graphqlconfig.yml with the following content:

projects:
  amplifyreact1:
    schemaPath: amplify/backend/api/amplifyreact1/build/schema.graphql
    includes:
      - src/graphql/**/*.js
    excludes:
      - ./amplify/**
    extensions:
      amplify:
        codeGenTarget: javascript
        generatedFileName: ''
        docsFilePath: src/graphql
        region: ap-southeast-1
        apiId: null
        maxDepth: 2
extensions:
  amplify:
    version: 3

Noticed that schemaPath changed and inclusions of several new settings.

Afterwards, I ran amplify api gql-compile && amplify codegen, it now works as expected.
Is there a reason as to why this had happened?

from amplify-codegen.

nubpro avatar nubpro commented on August 17, 2024 2

Is there a fix or some workaround for this? I'm still facing this issue.

#113 (comment)

from amplify-codegen.

phani-srikar avatar phani-srikar commented on August 17, 2024 1

The workaround is to re-compile your updated schema as mentioned here: #113 (comment)

from amplify-codegen.

Robbie-Cook avatar Robbie-Cook commented on August 17, 2024 1

Why in the name of all that is holy, do I need to use amplify api gql-compile && amplify codegen instead of just amplify codegen ffs

from amplify-codegen.

cjsilva-umich avatar cjsilva-umich commented on August 17, 2024 1

Three and a half YEARS later and the behavior is still not like the docs...

At least the mentioned workaround does the trick sometimes.

from amplify-codegen.

pagameba avatar pagameba commented on August 17, 2024

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.

from amplify-codegen.

binadamu-isiyoonekana avatar binadamu-isiyoonekana commented on August 17, 2024

@SwaySway Hi Josue. Any progress on this subject, as with latest version of Amplify (namely 4.41.0), nothing is generated/updated in src/graphql folder (i.e mutations, queries, ...) when entering amplify api gql-compile && amplify codegen. Thanks and Happy New Year !

from amplify-codegen.

SwaySway avatar SwaySway commented on August 17, 2024

@binadamu-isiyoonekana
Could you provide your .graphqlconfig.yml and the schema? If the schema contains sensitive information you can send it to our email [email protected]

from amplify-codegen.

vincent38wargnier avatar vincent38wargnier commented on August 17, 2024

I have exactly the same issue. I'm using codegen for months, and suddenly today it's not generating the code even if it's saying it's doing it :
image
And the Schema is well updated :
image

This is the graphql code I added to the API :

type NewsLetterSubscribers @model @auth(rules: [
  {allow: private, operations: [create]}
  {allow: public, operations: [create], provider: iam}
  {allow: public, operations: [read, update, create], provider: apiKey}
  ]) {
    id: ID!
    subscribed: Boolean!
    email: String!
    dateUnsubscribed: AWSDateTime
    reasonUnsubscribed: String
}

I have CLI version 4.44.0 on macOS

from amplify-codegen.

vincent38wargnier avatar vincent38wargnier commented on August 17, 2024

I made some tries with the mock, creating news tables, and looking at the same time what is happening in the mutation.js file.

It happens that at some point during the code gΓ©nΓ©ration the code of the new tables is created, but it's removed right away, I don't know why.

At this point the new code is created :
image
And at this point its removed :
image

This is all the things I have in my console :
image
So first line creates the code, and the second indentical line removes it. I don't know what to understand from that. It seems that an instance of the API is stucked in the codegen system, so the codegen does its work properly, and then the old instance does its work as well, so the code generated at the end is related to the API before the bug appeared.

But apparently removing the .graphqlconfig.yml file solves the pb. Thanks to aws-amplify/amplify-cli#50 (comment)

Btw removing, or reinstalling codegen didn't change anything

from amplify-codegen.

nubpro avatar nubpro commented on August 17, 2024

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.

This workaround you proposed does not seems to work.
src/graphql doesnt get updated after running the command you suggested, however schema.json is. Tested on 4.44.0

.graphqlconfig.yml

projects:
  amplifyreact1:
    schemaPath: src/graphql/schema.json
    includes:
      - src/graphql/**/*.js
    excludes:
      - ./amplify/**
    extensions:
      amplify:
        codeGenTarget: javascript
        generatedFileName: ''
        docsFilePath: src/graphql
        maxDepth: 2
extensions:
  amplify:
    version: 3

schema tested:

type Todo @model {
  id: ID!
  name: String!
  description: String
  test6: String <--- change this field name
}

from amplify-codegen.

siegerts avatar siegerts commented on August 17, 2024

Hi All, Thanks for keeping this updated and re-raising πŸ™ŒπŸ» .

The team is looking into this now to determine the best path forward, and will update this as soon as there is more information.

Just an fyi - this will be transferred over to the amplify-codegen repo for better tracking (once permissions are set).

Thanks again!

from amplify-codegen.

ankitmhn avatar ankitmhn commented on August 17, 2024

Is there a fix or some workaround for this? I'm still facing this issue.

from amplify-codegen.

stale avatar stale commented on August 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from amplify-codegen.

stale avatar stale commented on August 17, 2024

This issue has been automatically closed because of inactivity. Please open a new issue if you are still encountering problems.

from amplify-codegen.

pencilcheck avatar pencilcheck commented on August 17, 2024

After doing all those latest answer with new scripts, the model which are renamed in the cloud didn't get synced to the local JS files. All models created are synced but the existing models renamed are not replaced.

from amplify-codegen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.