Relay: [Modern][Question] Does Relay Modern support conditional fragments?

Created on 10 Aug 2017  路  2Comments  路  Source: facebook/relay

I have a parent level component that conditionally injects a child component in depending on if parameters have been given. Which means the root level fragment also changes along with it. Unfortunately this hasn't worked out for me as cleverly as I had hoped. Is this possible with Relay Modern?

I've found a similar case for Relay Classic, https://stackoverflow.com/questions/32577496/conditional-fragments-or-embedded-root-containers-when-using-relay-with-react-na but do not know if this is even supported or how it would be done in Modern.

I don't really like asking these types of things here, but the SO community for Relay is a bit sparse. Reference to OP regarding this: https://stackoverflow.com/questions/45595880/trying-to-create-a-more-dynamic-reusable-root-level-queryrenderer

Most helpful comment

it does support it

but it is trick

All 2 comments

it does support it

but it is trick

Relay Modern supports standard GraphQL @include(if: $cond) as well as @skip, check out the GraphQL spec on how to use it.

Was this page helpful?
0 / 5 - 0 ratings