After my tests, which work well, I created a role named Test Role and granted it to a user, as shown in the image below.
In Graph Explorer, you can obtain all the roles granted by the following request, including custom roles.
https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments?$filter=principalId+eq+'<object-id-of-principal>'
As shown in the image, the first one is a custom role for me.
For more information about this Api:
https://learn.microsoft.com/en-us/entra/identity/role-based-access-control/custom-assign-graph
Hope this helps.
If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.