General Apollo GraphQL discussions.
How do I get the response data in the mutation HOC into the react component so that I can conditionally render UI based on the data? https://gist.github.com/caseysiebel/6a8491904c0c373d3953898cffca05ef#file-exp-js-L10February 21, 2019 at 7:17pm (Edited 1 month ago)
February 21, 2019 at 7:23pm
why not use
Query HOC component and compose your query in such way so you can get the info you need?
seems like you are doing the login, based on your gist. my approach is to have
isLoggedIn = isLoggedIn() in default state, which checks the JWT and set's the stuff accordingly. then I use
PrivateRoute HOC that takes care of the login, There i have
Query component which always tells is the logged in status changed
i've never seen that approach :(
I'm logging the data there, yes. But what I want to do is get that data object into the Login component props
so i can conditionally display an error is the login was unsuccessful
does that make sense?
data is not null
that could ereally save your day. if you know of Redux, that's similar.
Feels like i should be able to just get that data into my react component
Not sure exactly what you're trying to accomplish, but something like this should allow you to pass server-thrown errors down to your component:
It looks like you're using formik so you'd probably want to leverage
setFieldError in a nicer way, but I think pulling from your
catch will be a better path to a nice UI