hasuranhost

Error thrown in Console, but not from app


"field 'todos' not found in type: 'query_root'"

I dont get this error if query is being run from application

but do get if it is run from Hasura Console

why?

the app is just a copy of nhost demo app

https://github.com/srghma/nativescript-testapp/blob/7ca234c4d95ec3415f8c2b8974103127cbad0cd7/docker-compose.yml#L48-L66

https://github.com/srghma/nativescript-testapp/blob/7ca234c4d95ec3415f8c2b8974103127cbad0cd7/nextjs-server-components/src/app/protected/todos/%5B%5B...pagination%5D%5D/page.tsx#L23

https://github.com/srghma/nativescript-testapp/blob/7ca234c4d95ec3415f8c2b8974103127cbad0cd7/nhost-backend/nhost/metadata/databases/default/tables/public_todos.yaml#L1

-- this is taken from hasura logs when I access http://localhost:3000/protected/todos page
x-hasura-role user
x-hasura-user-id e2edb294-514b-463a-84fa-4a43e004d09a
x-hasura-user-is-anonymous false

all ok if admin creating user1 creating user2 creating user3 take id with id query doesnt work permissions are ok

also posted here

https://github.com/hasura/graphql-engine/issues/10546


Solution

  • If you are using JWT authentication you can't just take the role and user-id from the logs and send those in the headers, you need to use a valid JWT token. The Hasura engine will extract your session variables like the user-id and role from the JWT.

    https://discord.com/channels/407792526867693568/1287397028804165642/1287798115339862098