Get requesting users ID in resolvers

Hello,

I’ve checked the a custom resolver event data, and I can’t seem to find the ID of the user making the request / the authentication token - is there any way to get the requesting users ID in the resolver event? similar to the createdById in a before/after hook?

Thanks

Hey @nce.softdev - good question! The event.data object won’t have this info. However, event.headers will have the auth token, which you’d be able to decode and get the requesting user’s email address. That said, if you need the User’s ID specifically, you can run an API call like so:

query {
  user { 
    id 
  }
}

The request will inherit the auth token and return the ID (and other fields you specify) of the requesting user. Hope this helps!