I have built and launched all the components for the whatsapp clone tutorial. My auth server is generating valid JWT (as per jwt.io) using symetric encryption. The JWT is passed by the react-app correctly it seems since I can signup and login. Now I have some problems that I'm not able to solve right after login using the react-app.
After login, our user is redirected to components/ChatsListScreen/ChatsList.tsx
. Here, we want to show data based on the connected user (using useMe()
). My problem is that useMe()
returns an empty object.
also I get the following error on the hasura server (running in docker):
{"timestamp":"2019-10-13T08:21:26.663+0000","level":"error","type":"http-log","detail":{"operation":{"query_execution_time":null,"user_vars":{"x-hasura-role":"user","x-hasura-user-id":"4"},"error":{"path":"$.variableValues","error":"expecting a value for non-nullable variable: userId of type: Int! in variableValues","code":"validation-failed"},"request_id":"5a8c6897-69dd-410e-bd10-f637750e1957","response_size":148,"query":{"variables":{},"operationName":"ChatsListQuery","query":"query ChatsListQuery($userId: Int!) {\n chat(order_by: [{messages_aggregate: {max: {created_at: desc}}}]) {\n ...chat\n users(where: {user_id: {_neq: $userId}}) {\n user {\n ...user\n __typename\n }\n __typename\n }\n __typename\n }\n}\n\nfragment chat on chat {\n id\n name\n picture\n owner_id\n created_at\n messages(order_by: [{created_at: asc}]) {\n ...message\n __typename\n }\n __typename\n}\n\nfragment message on message {\n id\n chat_id\n sender {\n id\n name\n __typename\n }\n content\n created_at\n __typename\n}\n\nfragment user on users {\n id\n username\n name\n picture\n __typename\n}\n"}},"http_info":{"status":200,"http_version":"HTTP/1.1","url":"/v1/graphql","ip":"172.18.0.1","method":"POST"}}}
As you can see x-hasura-user-id
is passed correctly, but the query expects a userId
which is empty.
From my logs, and what I understand, this is caused by the fact that fetchUser
that feeds the useMe()
hook is empty.
Now the reason why this is empty is most probably because my hasura database is empty. The auth server database has users (the ones that signed in) but the users
table from hasura is empty.
How does the users
table from hasura ever gets populated?