-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Plugins support in Amplify Codegen #6898
Comments
Will this RFC potentially resolve aws-amplify/amplify-codegen#474? Here are the methods I've tried:
I honestly think there's a lot of improvement to be made if you want developers to start taking amplify plugins seriously. The assumption that we know most of the things you guys know needs to be off the table. |
Hi @nubpro. This RFC would help you generate docs at multiple destinations by specifying multiple docs generation tasks. This will save you the hassle to copy over the generated docs to your lambda function. Thank you for your feedback. |
I support this RFC. Would make life a lot easier having the ability to dish out graphql files to separate locations. Example being many lambda functions. |
This is perfect! Thought it would be a smaller change, but seems like a much bigger, and a better thing. Btw, will cdk be able to invoke the "docgen", and generate graphql files based on the provided schema? Thanks @phani-srikar and the team for this very detailed proposal! |
Hello I support the RFC as it would be useful to codegen queries into multiple functions of various languages. IE we have a lot of nodejs but need to support python as well. Codegen queries and models into both of those directories would be very useful. Also codegen into a lambda layer etc. |
I would also like to register my support for this RFC. As Amplify projects grow it is almost inevitable that other systems (particularly Lambdas) will need to touch the provisioned datastores. Having code generated models for these systems would be incredibly helpful |
Where is this effort currently? This is something needed. Client -> GraphQL interaction is great out of the box, but more server side logic driven applications require graphql on the backend, and for that matter, potentially over multiple functions. |
+1. We have dozens of functions doing asynchronous processing in response to DynamoDB streams. Having to copy/paste the queries into each function inevitably leads to schema mismatches and bugs. |
We have a monorepo set up with multiple React front-end projects, along with several Lambda functions.
|
We have Lambda functions in Go and we also want to reuse the generated GraphQL code. |
Hey @chrisl777, I feel your pain on this one. Our team ended up managing all of our Amplify related resources in a package within our monorepo, other apps (we have a react-native app, some data processes, web app, etc.) import those resources from the Sounds like this doesn't quite fit with your current CRA pattern, but might encourage you to check out some monorepo tooling (nx, lerna, yarn workspaces, turborepo, etc.) |
Will this RFC also resolve aws-amplify/amplify-codegen#251? A more versatile approach could involve defining the depth of connection paths for specific queries. For instance, in the configuration file, we could stipulate the depth for necessary connections for a query like listInvoices as follows:
If the |
Thumbs up on this too - it's a bit odd I have to copy and paste code around to write my lambda functions. |
I stumbled across the following limitation today and while searching through Github issues was redirected here: When using multiple frontends with one Amplify backend as described in the docs here, when selecting 'no' for |
This is a Request For Comments (RFC). RFCs are intended to elicit feedback regarding a proposed change to the Amplify Framework. Please feel free to post comments or questions here.
Summary:
The current Amplify GraphQL code generator needs improvements to make it more flexible and easily extensible. This RFC describes a plugins based architecture together with a re-designed configuration which could make the Amplify GraphQL code generator more flexible by allowing customizations at plugin level and easily extensible by supporting custom code generator plugins.
Motivation:
The motivation for this proposal comes from several developer requests listed in the Related Issues below. To summarize, developers want :
A plugins based architecture also brings several advantages to the current state of Amplify GraphQL code generator:
@aws-amplify/graphql-typescript-types-generator
,@aws-amplify/graphql-swift-types-generator
etc.In the absence of a plugins based architecture, it would become increasingly difficult to maintain the current GraphQL code generation packages as the number of supported language targets increases with time.
It would also be harder to add customizations for each language target being code generated.
Detailed Design:
This is subject to change and will be updated in the RFC if need be. Any suggestions are welcome.
Some anticipated additions include:
Developer Experience:
The current GraphQL configuration (named
.graphqlconfig.yml
) is not well documented and its structure is confusing to developers. As part of this effort, we would like to make the configuration file as the source of truth for the generator. The amplify codegen add CLI walkthrough would help the developer create a minimal configuration file, which we will then prompt him/her to edit to add any customizations. We will clearly document how to create and maintain the configuration file.The
codegen add
workflow will generate the re-designed configuration which can be re-configured usingcodegen configure
.The
codegen statements
workflow will use the plugins defined in the statements section of the re-designed config to generate the GraphQL operations.The
codegen types
workflow will use the plugins defined in the types section of the re-designed config to generate the type annotations at corresponding output location. By default, types generators use the statements generation output. This behavior can however be customized to specify location to custom statements.The
codegen models
workflow will use the plugins defined in the models section of the re-designed config to generate the type annotations at corresponding output location. These are intended to be used in combination with Amplify Datastore.The
codegen
workflow will run the statements, types and models workflows.Refer Appendix for more information.
We will provide a guide to creating custom plugins for the developers. We will also provide API documentation for the supported plugins including the customizations they support.
Drawbacks and Adoption Strategy:
The developer would need to migrate to using the re-designed configuration.
We will continue to support the options that are present in the current configuration, for example, maxDepth, region, apiId etc. The output of the generators should remain the same when appropriately configured.
In addition to the detailed documentation for the re-designed configuration, we will provide a migration guide to help the developers quickly make the switch.
The initial release will provide a Feature Flag with a pre-defined deprecation date which allows the existing customers to test the plugins architecture before making the switch.
Related Issues:
amplify codegen
? amplify-codegen#44Appendix:
Architecture Overview
This section gives an overview of the re-designed architecture. It is subject to change and should be treated as a sample.
Consider a simple schema using a statements generator, two types generators and a models generator plugins:
amplify codegen statements
workflow: Generates GraphQL statements from a given GraphQL schema.amplify codegen types
workflow: Generates type annotations in specific target language from given GraphQL schema and GraphQL statements.amplify codegen models
workflow: Generates type annotations in specific target language from given GraphQL schema, to be used with Amplify Datastoreamplify codegen
workflow: Generates GraphQL statements from a given GraphQL schema. Then, uses the schema and the generated statements to generate type annotations in specific target language. Also, generates the type annotations called Datastore Models from the given GraphQL schema.The context being passed to various plugins will contain the information that it needs to generate the code.
Terminology:
References:
The current code generation packages (statements, types and models) can be found here
Special thanks to pointing out the following resources in some of the feature-requests:
The text was updated successfully, but these errors were encountered: