How to get Directus user data using GraphQL?

Viewed 1330

Is it possible to request Directus users' data using GraphQL query?

Even I have correct permissions, there are just two fields under query type.

fields

2 Answers

No, If you are just using GraphQL endpoint then it's not possible to get user data.

But you can use REST API instead of GraphQL. You can get user data using GET /users/me

Check similar StackOverflow answer

Yes, this is possible with the latest version (v9.5.0). The documentation says there’s feature parity between REST and GraphQL API.

Make sure to allow at a minimum read permissions for the ID in: Systems Collections / Directus Users

Also you’ll need to authenticate e.g. with an authorization token in the http headers:

{
 "authorization": "Bearer YOUR_TOKEN_HERE"
}
Related