javascript graphql add fragments conditionally

This is precisely what an @include directive is good for:

query fetchEvent($id: ID!, $idType: EventIdType!, $isBn: Boolean!) {
    event(id: $id, idType: $idType) {
        ...BnFields @include(if: $isBn)

Then, add isBn: lang === 'bn' to the variables you are passing along with the query.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top