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

[gql_code_builder] fix: vars_create_factories handle BuiltList type #447

Merged

Conversation

LiLatee
Copy link
Contributor

@LiLatee LiLatee commented Feb 16, 2024

Hi! 👋
I've tried to use that feature vars_create_factories and I've encounter an issue with arguments being lists. The parameter of a factory requires a BuiltList that is assigned to ListBuilder and that is not allowed.
image

@caffeineflo I've found some solution. Not sure whether it's the best way, but it works for me. So if you could take a look 🙏

@LiLatee LiLatee force-pushed the fix_vars_create_factories_for_built_list branch from 213bd98 to 8f3a467 Compare February 16, 2024 16:58
@LiLatee LiLatee changed the title fix: vars_create_factories handle BuiltList type [gql_code_builder] fix: vars_create_factories handle BuiltList type Feb 16, 2024
Copy link
Collaborator

@knaeckeKami knaeckeKami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also add a test with a list input in the end to end test repo so we don't break that again in a refactor

/// "$BuiltList" is a String "BuiltList<dynamic>" and
/// [g.returns!.symbol!] returns "BuiltList"
/// so we cannot use equality operator here.
final isBuiltList = g.returns?.symbol != null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also check the URL of the reference is from built_value, so we cannot have false positives here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I thought of doing that too to find Built Types at one point (when I wrote some of that code), but I think I didn't end up doing that as it was extremely hard to pin down the correct import.
For BuiltList s though, this would be checking for the built_lists import though, which doesn't change as often, right?

An alternative that might be worth exploring though, would be to check if all BuiltList instances are of type ListType and ListType is exclusively used for BuiltLists. Then you could "simply" add another check to L47

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the url of the Reference should be '"package:built_collection/built_collection.dart", I think this could just be added additionally to this check to avoid clashes with types from the schema, which theoretically also could contain symbols that contain the name BuiltList

Copy link
Contributor Author

@LiLatee LiLatee Feb 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅

@@ -165,7 +165,7 @@ class SubscriptionData extends GraphQLSocketMessage {
int get hashCode => toJson().hashCode;

@override
bool operator ==(dynamic other) =>
bool operator ==(Object other) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an unrelated change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. To be honest I cannot figure out why but the analyzer was failing
image

Your commit was the last one and then it was succeeding. Now it doesn't 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe because workflow uses dart:latest, so something in the Dart could change.
image

Copy link
Collaborator

@knaeckeKami knaeckeKami Feb 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's likely a new default lint rule in dart

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this was the change dart-lang/sdk@aad9e57

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find that 😅

@knaeckeKami knaeckeKami merged commit dee7eed into gql-dart:master Feb 17, 2024
20 checks passed
@LiLatee LiLatee deleted the fix_vars_create_factories_for_built_list branch February 17, 2024 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants