Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

How to pass nested fragments #394

Open
baconcheese113 opened this issue Jun 21, 2022 · 2 comments
Open

How to pass nested fragments #394

baconcheese113 opened this issue Jun 21, 2022 · 2 comments

Comments

@baconcheese113
Copy link

baconcheese113 commented Jun 21, 2022

If I have a query and fragments like below

query Home {
  user {
    id
    ...fragment1_user
  }
}

fragment fragment1_user on User {
  __typename
  id
  firstName
  ...fragment2a_user
  ...fragment2b_user
}

fragment fragment2a_user on User {
   __typename
  id
  lastName
}

fragment fragment2b_user on User {
  __typename
  id
  email
}

When I try to pass the props to their child widgets inside the Fragment1 Widget:

Fragment2aWidget(userFrag: widget.userFrag),
Fragment2bWidget(userFrag: widget.userFrag),

I get the following errors:

The argument type 'Fragment1UserMixin' can't be assigned to the parameter type 'Fragment2aUserMixin'.
The argument type 'Fragment1UserMixin' can't be assigned to the parameter type 'Fragment2bUserMixin'.

From the Home to Fragment1 widgets I see I'm able to pass Home$Query$User to the Fragment1UserMixin type, but I can't pass the others. I could probably just cast to the child mixin types, but that prevents static analysis on the values I'm passing in.

Am I missing something?

@vasilich6107
Copy link
Collaborator

Look at how the code is generated.
As far as I understand- it’s mostly relates to how dart type system work.
Maybe you’ll be able to find suitable approach

@baconcheese113
Copy link
Author

It appears like the runtimeTypes aren't changing, that's preventing passing nested fragments farther down the widget tree

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants