relay icon indicating copy to clipboard operation
relay copied to clipboard

[relay-lsp] Add a refactor to turn global variable into explicit fragment argument

Open tobias-tengler opened this issue 5 months ago • 1 comments

tobias-tengler avatar Jan 25 '24 21:01 tobias-tengler

Might be more correct to say "turn a global variable reference into an explicit fragment argument".

I'm imagining it would turn this:

fragment UserProfile_fragment on User  {
  name
  profile_picture {
    url(scale: $scale) # <-- Right click here to refactor...
  }
}

query($scale: Float!) {
  me {
    ...UserProfile_fragment
  }
}

Into:

fragment UserProfile_fragment on User @argumentDefinitions(
  scale: {type: "Float"} # <--  Maybe you could even have the ability to specify this as a new local name?
) {
  name
  profile_picture {
    url(scale: $scale)
  }
}

query($scale: Float!) {
  me {
    ...UserProfile_fragment @arguments(scale: $scale)
  }
}

captbaritone avatar Jan 25 '24 23:01 captbaritone