GraphQL response contains both error and data when fetching user with JWT

System Information
  • Strapi Version: 4.5.4
  • Operating System: Win 10
  • Database: PostgresQL latest
  • Node Version: 16.13.2
  • NPM Version: 8.1.2
  • Yarn Version:

Hello, everyone!

I’m learning authentication with Strapi and GraphQL.

When I’m performing a test request with JWT, to fetch the data of a newly created user, the GraphQL playground shows response containing both error (forbidden access) object and user data, that… is not supposed to be there in case if error attached, I guess?

If I delete JWT from headers, the data is null with error, as expected.

But, is it okay for the error object to be there if the data is successfully retrieved? Meaning we should check the response based on if data is null, not if error object is present? Or, am I doing something wrong?