and isUser() and state.isUser is `false`, but when...
# prisma-whats-new
v
and isUser() and state.isUser is
false
, but when I try to createUser, graph.cool says user with details already exists, and I've verified that in the console
a
the
user
query is to get the currently logged in user, based on the Authorization token that is passed in with the query.
To see if a user exists, you can use (for example):
Copy code
query { User(emailAddress: "x@y.z") { id } }
v
I actually want the currently logged in user. When I run the userQuery manually, I get the correct details (id, name, emailAddress) - but this.props.data.user is undefined. I'm pretty sure the issue is that it's not waiting for apollo to check the props after they are set
d
@valid are you checking
this.props.data.loading
?
v
d
well and where you are calling
setState
?
v
I'm not presently -- that was added as a test -- 1s, let me remove that and just use this.props.data.user instead of state
d
yea, it just confuses things to use state there 🙂
also those console.log are useless, data wont be loaded in constructor for sure, if you want to log out things, use
componentWillReceiveProps
v
Good to know! 🙂
d
and this still gives you undefined ? in that case I would recheck that authentication really works, although it should be returning
null
in that case
v
So with this code, I'm getting
null
on initial load (before auth, expected) - then after auth, it's null again, even though localStorage has the full profile and token and such -- I have to refresh the page for it to correctly register logged in state
on refresh, it shows the logged in page
d
oh and you should also check
props.data.error
, that's important part of Apollo flow too
v
I can share Login.js if needed, but pretty sure App.jsx should be handling this aspect.
Ah, I'll add that in
d
it's possible you are getting some error there, but just ignoring it 🙂
v
Just checked, no errors being triggered
d
personally I am not using Auth0, it's too bloated for me and I never studied tutorials with Graphcool, so maybe there is something you have missed? I have working authentication with Firebase and never run into issues like that ... sorry I cannot help you more
v
No worries, thanks for trying
maybe I'll look into Firebase