GraphQL Cookbook

Getting a logged user through the Parse GraphQL API

Problem

You want to get a logged user’s data from your backend through the Parse GraphQL API.

Solution

Using the Parse GraphQL API, you can get a logged user’s data just by sending the user’s sessionToken through the X-Parse-Session-Token header (as described in the authenticating a user recipe) and calling the me query.

Example:
1
2
3
4
5
6
7
8
9
10
11
query Me {
  users {
    me {
      objectId,
      createdAt,
      updatedAt,
      username,
      sessionToken
    }
  }
}
Result:
1
2
3
4
5
6
7
8
9
10
11
12
13
{
  "data": {
    "users": {
      "me": {
        "objectId": "NyU1lNlhPd",
        "createdAt": "2019-07-29T09:09:58.222Z",
        "updatedAt": "2019-07-29T09:09:58.222Z",
        "username": "somefolk",
        "sessionToken": "r:cbca71d29d7601761b48ed01bbe9638d"
      }
    }
  }
}