Session Operations
This section covers GraphQL operations related to user session management.
Queries​
My Active Sessions​
Retrieves all active sessions for the currently authenticated user.
query MyActiveSessions {
myActiveSessions {
id
token
user
expiresAt
createdAt
isActive
ipAddress
countryCode
userCountryCode
state
timezone
context {
OS
OSVersion
browser
browserVersion
}
currentDevice
}
}
Response:
{
"data": {
"myActiveSessions": [
{
"id": "session-id-1",
"token": "session-token-1",
"user": "user-id",
"expiresAt": "2023-01-02T00:00:00Z",
"createdAt": "2023-01-01T00:00:00Z",
"isActive": true,
"ipAddress": "192.168.1.1",
"countryCode": "US",
"userCountryCode": "US",
"state": "California",
"timezone": "America/Los_Angeles",
"context": {
"OS": "macOS",
"OSVersion": "12.6",
"browser": "Chrome",
"browserVersion": "108.0.0"
},
"currentDevice": true
},
{
"id": "session-id-2",
"token": "session-token-2",
"user": "user-id",
"expiresAt": "2023-01-02T00:00:00Z",
"createdAt": "2023-01-01T00:00:00Z",
"isActive": true,
"ipAddress": "192.168.1.2",
"countryCode": "GB",
"userCountryCode": "US",
"state": null,
"timezone": "Europe/London",
"context": {
"OS": "iOS",
"OSVersion": "16.0",
"browser": "Safari",
"browserVersion": "16.0"
},
"currentDevice": false
}
]
}
}
Stream Chat Token​
Retrieves a Stream Chat token for the currently authenticated user.
query StreamChatToken {
streamChatToken
}
Response:
{
"data": {
"streamChatToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
}
Session Model​
Fields​
Field | Type | Description |
---|---|---|
id | ID | Unique identifier for the session |
token | String | Session token |
user | ID | ID of the user the session belongs to |
expiresAt | Date | Date and time when the session expires |
createdAt | Date | Date and time when the session was created |
isActive | Boolean | Whether the session is currently active |
ipAddress | String | IP address associated with the session |
countryCode | CountryCode | Country code detected from the IP address |
userCountryCode | CountryCode | Country code set by the user in their profile |
state | String | State or region of the session |
timezone | String | Timezone of the session |
context | SessionContext | Additional context information about the session |
currentDevice | Boolean | Whether the session is from the current device |
Session Context Fields​
Field | Type | Description |
---|---|---|
OS | String | Operating system name |
OSVersion | String | Operating system version |
browser | String | Browser name |
browserVersion | String | Browser version |