Amplify-js: Can I use Amplify Codegen on an existing schema?

Created on 21 Nov 2018  路  11Comments  路  Source: aws-amplify/amplify-js

* Which Category is your question related to? *
amplify codegen

* What AWS Services are you utilizing? *
AppSync

* Provide additional details e.g. code snippets *
I am wondering if it is possible to generate flowtypes based of an existing appsync graphql schema?

The project was not done using Amplify init. I was able to use aws-appsync-codegen in the past, but its not maintained any longer + does not have support for AWSDate etc.

question

Most helpful comment

@yuth I figured it out. I had a .graphqlconfig.yml hanging around from a previous amplify init. Once I deleted it, it worked.

All 11 comments

Amplify does support adding external Appsync API by passing --apiId <api-id> to the add command. It still needs a project to be initialized to use it (even if you don't use it to publish).

If this doesn't fit your need, you could use amplify-graphql-docs-generator and amplify-graphql-types-generator, which amplif-cli uses internally. Both these packages have their own CLI (albeit limited)

We still don't have support for AWSDate in the codege. We have this feature request in our backlog.

If I run amplify init followed by amplify add codegen --apiId XXX I get the error message Codegen support only one GraphQL API per project

@jpaas What version of amplify do you have? Could you also paste the output you get when running amplify ls on your project

@yuth I figured it out. I had a .graphqlconfig.yml hanging around from a previous amplify init. Once I deleted it, it worked.

hey @jpaas I am trying to use your approach, but I don't have the file .graphqlconfig.yml at all, I check the root and all the files within. The project is in Desktop. Have any idea to solve it? Thanks

@skc18 If you're using file explorer, you won't be able to view the .graphqlconfig.yml file. Please use an editor or the terminal to view the file. Also, please let me know if you're still stuck on this.

@skc18 you might need to do > amplify codegen remove

@wallowabk You are my hero.

Thanks @wallowabk

Most of the scenarios observed in this issue would be a lot simpler to resolve if the error message was not misleading and contained resolution steps. For example, I think that we should replace
Codegen support only one GraphQL API per project with Amplify currently only supports creation of a single GraphQL API codegen configuration file (.graphqlconfig.yml) per project.

@yuth I figured it out. I had a .graphqlconfig.yml hanging around from a previous amplify init. Once I deleted it, it worked.

That fixed my problem too. Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

guanzo picture guanzo  路  3Comments

callmekatootie picture callmekatootie  路  3Comments

ldgarcia picture ldgarcia  路  3Comments

epicfaace picture epicfaace  路  3Comments

romainquellec picture romainquellec  路  3Comments