System Information
- Strapi Version: 3.6.5
- Operating System:
- Database:
- Node Version:
- NPM Version:
- Yarn Version:
Hi everyone
I am currently working on a side project in order to try the great cms Strapi.
I have a question concerning error handling in Strapi with graphql. I was playing with the graphql playground and tried some queries/mutations. There is one thing I canât figure out.
Letâs say I want to register a new user. I use the âregisterâ mutation
It works perfectly.
Now if I omit the password I got this response
which is nice, because I can handle this message on my front-end app. I checked on the strapiâs github to see how it is managed strapi/Auth.js at master ¡ strapi/strapi ¡ GitHub. We can see in the controller the action âregisterâ which returns a BadRequest if the password is empty :

Thatâs perfect.
Next, I tried the âupdateUserâ mutation which works pretty well
However, if I let the username empty, I got this error
I checked the âupdateâ action strapi/api.js at master ¡ strapi/strapi ¡ GitHub and we can see a badrequest is returned if the username is empty
I was wondering why I donât get this error message in the graphql response whereas for the register action I can handle it ? Instead I got âCannot return null for non-nullable field UsersPermissionsUser.id.â (which I understand, if no user is returned, I canât access user ID)
If someone can help me
Thanks !