Is it possible to optionally include parameters when creating a Relay query?
See below I'm querying resources, and I'm hard coding the params here.
I would like to conditionally include some of these arguments, for example date_gt and date_lt. At the moment I have to set initial values for these, but that falls apart as I need to query for records without dates at all.
If I can't do that is it possible to send null
as a value to a param here because I'm not having much luck with that either at the moment.
fragments: {
viewer: () => Relay.QL`
fragment on Viewer {
resources(
first: $pageSize
q: $q
type: $types
license: $licenses
order: $order
access_rights: "published"
orphan: true
date_gt: $dateFrom
date_lt: $dateTo
)
{
total
edges {
node {
${ArticleResult.getFragment('resource')}
}
}
pageInfo {
hasNextPage
}
}
}
`
},