Skip to content


Placeholder for the currently logged in user.



ObjectField: "@currentUserId"


The @currentUserId is a special, request execution time directive that returns the current logged in user. So instead of passing the user id through as an operation argument, the user id (subject in OAuth 2.0 terms) is taken out of the access token passed through, and matched with any user tables (i.e. those specified with a @bb_user directive). It will then use the internal user id from the user table in place of the @currentUserId directive. This is useful when the client does not have knowledge of the internal user id or it you do not want anyone to be able to run this operation against many different users (for example, in an attempt to get data for other users).


Basic INSERT resolver example using an input object
type PatientUser @bb_user {
  id: ID!
  name: String

type PatientAddress {
  id: ID!
  patient: Patient!
  address: String

# insert a patient's address. Notice that only the address is passed in, not the user id
insertAddressForLoggedInPatient(address: String): PatientAddress!
  _type: INSERT,
  _object: PatientAddress,
  _fields: {
    patient: {
      # this will create a link to the Patient in the 
      # Patient table using the currently logged in 
      # user's internal database id.
      id: "@currentUserId"
    address: "$address"

Last update: 2023-11-14