0

I have the following fragment definition

  fragment LocationFragment_viewer on Viewer
    @argumentDefinitions(userId: {type: "Int!"}) {
    results: locations(
      user_id: $userId
    ) {
      ...some_other_fragments
    }
  }

I want to change the argument from user_id to user_ids (which is just an array wrapping the id) in the GraphQL query, without changing the argument definition.

So I want something like:

  fragment LocationFragment_viewer on Viewer
    @argumentDefinitions(userId: {type: "Int!"}) {
    results: locations(
      user_ids: [$userId]
    ) {
      ...some_other_fragments
    }
  }

Is this even possible? In my case it is a bit hard to change the argument definitions, so trying to see if there is something easy to do without going that route.

Thank you!

HeyThere
  • 503
  • 1
  • 5
  • 19

1 Answers1

0

I found that Relay has added support for this in https://github.com/facebook/relay/releases/tag/v8.0.0

This means arguments can be composed like:

inputs: [{query: $my_query}, $other_input, null, $another_input]

Exactly what I need!

HeyThere
  • 503
  • 1
  • 5
  • 19