How can I use an id from my props in my graphql qu...
# prisma-whats-new
j
How can I use an id from my props in my graphql query?
Copy code
export default compose(
  // TODO: put this user's id into the filter (somehow)
  graphql(USER_QUERY),
  graphql(ALL_REPORTS, {
    options: props => ({
      $userId: props.data.user.id
    })
  }),
)(ReportsHome);
This doesn’t work since the user id is being retrieved alongside the reports
d
I think you'd want lift your user state into a higher state?
higher level component I mean
j
Good point. It would be great if I could just have the user id in the props all the time (that a user is logged in). Any idea how to do that?
d
oh wait have you tried switching the order of the graphql(...) calls inside compose?
j
No. Also, now that I’m thinking about it if my permissions are set right I shouldn’t even have to filter…right?
It should only return those reports that am permitted to see
d
not really sure about that. sry
j
No problem, thanks
Looks like it isn’t the case
Which seems odd
m
Not sure if you figured this out but this is what I did to get props from match on the router
Copy code
graphql(GET_ITEM, {
    skip: ownProps => !ownProps.match.params.id,
    options: ownProps => ({ variables: { itemCode: ownProps.match.params.id } }),
    fetchPolicy: 'network-only',
  }),