Using global node IDs

The node id is a globally unique identifier of an object. It is needed when you call the GraphQL query and mutation. In this section, we will go through how to generate the node ID for calling the Admin GraphQL API.

The node id is a base64url encoded string with the format of <NODE_TYPE>:<ID>. For example, in User:97b1c929-842c-415c-a7df-6967efdda160 , the node is "User" while "97b1c929-842c-415c-a7df-6967efdda160" is the ID for a specific user.

1. Generate id for User node type

You can use your preferred programming language or tool to encode node IDs to base64url as shown below:

package main

import (
	"encoding/base64"
	"fmt"
)

func main() {
	nodeID := base64.RawURLEncoding.EncodeToString([]byte("User:97b1c929-842c-415c-a7df-6967efdda160"))
	fmt.Println(nodeID)
}

Fetch the User object example

The query:

query {
  node(id: "<BASE64URL_ENCODED_USER_NODE_ID>") {
    ... on User {
      id
      standardAttributes
    }
  }
}

2. Generate id for AuditLog node type

package main

import (
	"encoding/base64"
	"fmt"
)

func main() {
	nodeID := base64.RawURLEncoding.EncodeToString([]byte("AuditLog:000000000004d2e7"))
	fmt.Println(nodeID)
}

Fetch AuditLog object example

Query:

{
  node(id: "<BASE64URL_ENCODED_AUDIT_LOG_NODE_ID>") {
    ... on AuditLog {
      id
      data
    }
  }
}

3. Generate id for Session node type

package main

import (
	"encoding/base64"
	"fmt"
)

func main() {
	nodeID := base64.RawURLEncoding.EncodeToString([]byte("Session:8891767c-992c-4c09-bbae-9a8337ae661k"))
	fmt.Println(nodeID)
}

Fetch Session object example

Query:

{
  node(id: "<BASE64URL_ENCODED_SESSION_NODE_ID>") {
    ... on Session {
      id
      displayName
      type
      createdAt
    }
  }
}

4. Generate id for Authenticator node type

package main

import (
	"encoding/base64"
	"fmt"
)

func main() {
	nodeID := base64.RawURLEncoding.EncodeToString([]byte("Authenticator:95435c90-8501-4735-a8b6-412601605a25"))
	fmt.Println(nodeID)
}

Fetch Authenticator object example

Query:

{
  node(id: "<BASE64URL_ENCODED_AUTHENTICATOR_NODE_ID>") {
    id
    ... on Authenticator {
      id
      kind
      createdAt
    }
  }
}

5. Generate id for Authorization node type

package main

import (
	"encoding/base64"
	"fmt"
)

func main() {
	nodeID := base64.RawURLEncoding.EncodeToString([]byte("Authorization:12345a90-7801-41d5-c3b6-655501605b56"))
	fmt.Println(nodeID)
}

Fetch Authorization object example

Query:

{
  node(id: "<BASE64URL_ENCODED_AUTHORIZATION_NODE_ID>") {
    id
    ... on Authorization {
      id
      clientID
      scopes
      createdAt
    }
  }
}

6. Generate id for Identity node type

package main

import (
	"encoding/base64"
	"fmt"
)

func main() {
	nodeID := base64.RawURLEncoding.EncodeToString([]byte("Identity:12345a90-7801-41d5-c3b6-655501605b56"))
	fmt.Println(nodeID)
}

Fetch Identity object example

Query:

{
  node(id: "<BASE64URL_ENCODED_IDENTITY_NODE_ID>") {
    id
    ... on Identity {
      id
      claims
      type
    }
  }
}

Last updated