Comments (19)
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.
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.
Why in the name of all that is holy, do I need to use
amplify api gql-compile && amplify codegen
instead of justamplify 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.
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.
Is there a fix or some workaround for this? I'm still facing this issue.
from amplify-codegen.
The workaround is to re-compile your updated schema as mentioned here: #113 (comment)
from amplify-codegen.
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.
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.
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.
@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.
@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.
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 :
And the Schema is well updated :
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.
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 :
And at this point its removed :
This is all the things I have in my console :
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.
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.
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.
Is there a fix or some workaround for this? I'm still facing this issue.
from amplify-codegen.
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.
This issue has been automatically closed because of inactivity. Please open a new issue if you are still encountering problems.
from amplify-codegen.
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)
- Missing Types HOT 2
- Amplify codegen doesn't support namespace queries/mutations HOT 3
- allow customizing generated graphql
- Allow saving patch changes to generated code HOT 2
- Incorrect __typename Generation on Custom Type HOT 1
- Angular code generation for v6 amplify HOT 5
- Cannot generate Models from GraphQL schema HOT 2
- Cannot use 'in' operator to search for 'name' in amplify codegen [UPDATE] HOT 6
- Gen 2 codegen generates wrong getters for "id" field in a model HOT 3
- Amplify codegen and EOENT model-introspection.js/schema.js HOT 3
- Types not generated for non null return types for mutations HOT 1
- Build fail on unknown type from GraphQL Scheme HOT 4
- [WARN] 16:19.312 DataStore - Skipping incoming subscription. HOT 7
- Mutations break after aws-amplify/cli update: "input contains a field that is not defined" HOT 10
- Unable to generate operations.graphql HOT 5
- unnecessary_non_null_assertion for `updatedAt` and `createdAt` in `toString()` from dart generator
- Amplify Configure Codegen FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory HOT 3
- Gen2 Swift Codegen for one-to-one does not compile
- Gen2 Data allow.ownersDefinedIn("owners") does not generate "owners" field on Swift model HOT 6
- how to fix graphql query can't get full result? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amplify-codegen.