Hello Francisco Javier Gomariz Abril,
Thank you for reaching out to Microsoft!!
For creating appRoleAssignment for a user using Graph API, in delegated scenarios please make sure one of the roles are present for the signed in user as per the official documentation referenced below:
Link: Create appRoleAssignment
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.