Skip to content

Generating tristate_optionals generates invalid code with mixed up imports #582

Open
@thomas7D

Description

@thomas7D

I need to use tristate optionals for my mutations and ran into invalid code generation when enabling it.

I recreated the issue in a simple project.

The generated test.var.gql.dart contains errors as it's mixing up the imports when using the tristate classes.

import 'package:ferry_test/__generated__/serializers.gql.dart' as _i1;
import 'package:gql_tristate_value/gql_tristate_value.dart' as _i2;
...
      b..name = const _i2.AbsentValue();
...
if (_$namevalue case _i1.PresentValue(value: final _$value)) {

In some lines it uses the correct import _i2 for the tristate value, in other it's wrong leading to syntax errors.

I haven't figured out what causes this issue as it's not present in all cases.
In the example project you can comment out the Pokemons query in lib/test.graphql and the code generation works as expected. But when both query and mutation are present the code is broken.

The same problems also occured in the generated schema files in a larger project when modifying that, with no obvious correlation between the changes in the schema and the mixing of imports.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions