vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
Other
5.73k stars 1.02k forks source link

ActiveCustomer Query can not query the user roles. #3010

Open arrrrny opened 2 months ago

arrrrny commented 2 months ago

Describe the bug When a customer is authenticated in the shop-api, it has the 'User' data type for the user field. 'User' field has roles property, when I try to query roles from the user, I get an error.

To Reproduce in shop api Authenticate a customer, which already has customer as the user role, and try to query below. Screenshot 2024-08-13 at 9 29 00 PM

if roles are omitted, query works just fine

Screenshot 2024-08-13 at 9 29 21 PM

Expected behavior Expected behavior is to ber able to fecth the user roles as defined in the return data type, or have CurrentUser data type as the returned data type for the user field.

If I query it from the Admin API as an admin , all is good.

Screenshot 2024-08-13 at 9 28 04 PM

Environment (please complete the following information):

Additional context Add any other context about the problem here.

michaelbromley commented 2 months ago

Thanks for the report. This occurs because we are missing a field resolver for the roles field on the User type.

We should add one here: https://github.com/vendure-ecommerce/vendure/blob/b5f41f04f79ac15e3656b879beb6f118a381b4e2/packages/core/src/api/resolvers/entity/user-entity.resolver.ts#L13

Are you interested in making a PR for this?

arrrrny commented 2 months ago

Thanks for the report. This occurs because we are missing a field resolver for the roles field on the User type.

We should add one here:

https://github.com/vendure-ecommerce/vendure/blob/b5f41f04f79ac15e3656b879beb6f118a381b4e2/packages/core/src/api/resolvers/entity/user-entity.resolver.ts#L13

Are you interested in making a PR for this?

Here you go

https://github.com/vendure-ecommerce/vendure/pull/3011