Skip to main content

Get the logged-in user

Retrieve the currently authenticated user's profile and company information.

Query

query GetViewer {
viewer {
... on Contact {
contactId
firstName
lastName
email
gender
primaryLanguage
company {
companyId
name
}
}
}
}

Response

{
"data": {
"viewer": {
"contactId": 1042,
"firstName": "Jan",
"lastName": "de Vries",
"email": "jan@acme.nl",
"gender": "M",
"primaryLanguage": "NL",
"company": {
"companyId": 141,
"name": "ASML Veldhoven"
}
}
}
}

How it works

The viewer query returns the user associated with the current JWT token. It returns the IBaseUser interface, so use an inline fragment (... on Contact) to access contact-specific fields like contactId and company. If no user is authenticated, the query returns null. This query is typically called on page load to check the session state and populate the header with the user's name and company.

See also