3

Example fragment:

fragments: {
  viewer: () => Relay.QL`
    fragment on Viewer {
      people(first: $limit orderBy: $orderBy) {
        count
        edges {
          node {
            id,
            ${PersonListItem.getFragment('person')},
          },
        },
      }
    }
  `,
},

The orderBy argument accepts the following enum values: firstNameASC/firstNameDESC/lastNameASC/lastNameDESC.

When doing this.setVariables({orderBy: 'firstName'}) the orderBy variable is passed as a string to the GraphQL server.

How do I pass any of these variables into Relay's setVariables without them being sent as strings?

Alex
  • 1,689
  • 18
  • 27

1 Answers1

5

You can now use an enum variable as a string.

Example

Query (EventsConnectionOrder is an enum)

query($orderBy: [EventsConnectionOrder]){
  viewer {
    events(first:1 orderBy: $orderBy) {
      edges {
        node {
          id
        }
      }
    }
  }
}

Variables

{
  "orderBy": "dateASC"
}
Alex
  • 1,689
  • 18
  • 27