aws-amplify / aws-amplify/amplify-codegen

Flutter: Import statements on generated models don't use a prefix causing type confusion

Open
#485 0 comments 0 reactions 0 assignees View on GitHub
bug p2
Dominant language
TypeScript
Stars
59
Forks
64
PR merge metrics
No merged PRs in 30d

Description

### Before opening, please confirm:

- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-codegen/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-codegen/blob/main/CONTRIBUTING.md#bugs).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

### How did you install the Amplify CLI?

npm

### If applicable, what version of Node.js are you using?

v16.14.2

### Amplify CLI Version

9.2.1

### What operating system are you using?

macOS

### Amplify Codegen Command

codegen models

### Describe the bug

First of all this is flutter related!

When declaring types in the schema.graphql e.g. `enum EventType { a, b }` that do exists in terms of naming in the imported packages in the generated files from codegen, flutter is not able to resolve the correct type as it exits two times then.

image

### Expected behavior

All self created types can be choosen (by name)

### Reproduction steps

Declare a `enum EventType { a, b }` in the schema.graphql and use this type in an entity in the schema.graphql and then `amplify push` `amplify codegen models` .

The generated files are not compile able by default.

### GraphQL schema(s)

```graphql
# Put schemas below this line

```

### Log output

```
# Put your logs below this line

```

### Additional information

This can easy be solved if the imports:

```dart
import 'ModelProvider.dart';
import 'package:amplify_core/amplify_core.dart';
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
```

would be written like:

```dart
import 'ModelProvider.dart';
import 'package:amplify_core/amplify_core.dart' as amplify_core;
import 'package:collection/collection.dart' as collection;
import 'package:flutter/foundation.dart' as flutter_foundation;

```

beacuse now all types can be resolved correctly. Of course this prefix now needs to be added anywhere where its used!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.