Skip to content
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

Support Amplify Codegen In Pure Dart Projects #858

Open
2 tasks
verygoodstefan opened this issue Jul 23, 2024 · 2 comments
Open
2 tasks

Support Amplify Codegen In Pure Dart Projects #858

verygoodstefan opened this issue Jul 23, 2024 · 2 comments
Labels
feature-request New feature or request

Comments

@verygoodstefan
Copy link

Describe the feature you'd like to request

It would be nice to have the ability to leverage features of Amplify Gen 2 (particularly the graphql model gen) in pure Dart packages, in addition to in Flutter projects. This would allow devs to integrate new Amplify features in projects and create packages that could be used in multiple Flutter apps, instead of being bound to a single app.

Currently, this is not possible because of how GraphQL model code is generated into Dart. Specifically, this generated constructor passes in a Flutter app, but throws a field_initializer_not_assignable error in a Dart app:

  const Todo._internal({required this.id, content, createdAt, updatedAt}): _content = content, _createdAt = createdAt, _updatedAt = updatedAt;

Describe the solution you'd like

It would be nice if the codegen that generates Dart code from the backend schema generates code that is supported in pure Dart packages.

Describe alternatives you've considered

The only alternative I can think of would be to only use Amplify on Flutter apps, not Dart packages, which would require repeating schema definitions across multiple Dart projects, and prohibit abstracting model generation within app architecture.

Additional context

No response

Is this something that you'd be interested in working on?

  • 👋 I may be able to implement this feature request

Would this feature include a breaking change?

  • ⚠️ This feature might incur a breaking change
@verygoodstefan verygoodstefan added the pending-triage Issues that need further discussion to determine label Jul 23, 2024
@stefanhk31
Copy link

Update: it turns out this does compile in pure Dart -- the root issue was my use of strict analysis rules in very_good_analysis.

Ignoring the Amplify-generated Dart code in analysis_options.yaml solves the issue.

@dpilch
Copy link
Member

dpilch commented Jul 29, 2024

I'll keep this as a feature request to modify the generated code to be compliant with very_good_analysis. In the mean time (as you have mentioned), ignore the generated files from any code analysis tools that cause issues.

@dpilch dpilch added feature-request New feature or request and removed pending-triage Issues that need further discussion to determine labels Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants