Relay: [Modern] FlattenTransform: Cannot flatten fragment spread %s with arguments. Use the `ApplyFragmentArgumentTransform` before flattening

Created on 22 Sep 2017  路  9Comments  路  Source: facebook/relay

I am getting this error:
https://github.com/facebook/relay/blob/master/packages/relay-compiler/graphql-compiler/transforms/FlattenTransform.js#L160

Could someone explain how to use suggested ApplyFragmentArgumentTransform ?

I could not find any examples or documents regarding ApplyFragmentArgumentTransform.

wontfix

Most helpful comment

@jantoebes would you mind explaining that solution? I don't understand that if A is a fragmented component you can just do A_viewer without the spread? Also, later you do ...A_viewer_fragment, but what is that _fragment? Thanks

All 9 comments

Facing the same issue.

I am having the same issue. My use case was trying to add @relay(mask: false) onto a fragment and got an error.

ERROR:
RelayMaskTransform: Cannot unmask fragment spread `A_viewer` with arguments. Use the 'ApplyFragmentArgumentTransform' before flattening

and the query is like this

  query {
    viewer {
      ...A_viewer @relay(mask: false) @arguments(...)
    }
  }

try this

...A_viewer @arguments(...) @relay(mask: false)

Do you mean moving @relay(mask: false) to the end?
I tried but the error didn't go away.

Did you figure this out? I am facing the same issue

I've put a question up here: https://stackoverflow.com/questions/49648794/error-when-trying-to-unmask-relay-modern-fragment-that-has-arguments

Hopefully we can get to the bottom of this 馃挭

the only way to fix it is like

  query {
    viewer {
      A_viewer @arguments(...) {
        ...A_viewer_fragment  @relay(mask: false)
      }
    }
  }

so you can the share the properties of the viewer fragment but not the total fragment

@jantoebes would you mind explaining that solution? I don't understand that if A is a fragmented component you can just do A_viewer without the spread? Also, later you do ...A_viewer_fragment, but what is that _fragment? Thanks

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings