How to access Tanzu Hub GraphQL API via Altair
search cancel

How to access Tanzu Hub GraphQL API via Altair

book

Article ID: 436689

calendar_today

Updated On:

Products

VMware Tanzu Platform - Hub

Issue/Introduction

Tanzu Hub provides a built-in GraphQL client (Altair) that allows developers and platform engineers to explore the schema, test queries, and execute mutations directly within the platform.

 

Tanzu Hub is built on an "API-first" architecture where all assets and operations are accessible through a public GraphQL API. To facilitate rapid development and troubleshooting, Tanzu Hub includes a local instance of the Altair GraphQL Client.

Environment

Tanzu Hub

Cause

 

Resolution

Prerequisites

  • Permissions: You must have a Tanzu Platform Admin or appropriate service role to access API tools.
  • Authentication Token: You will need a valid Bearer token. This can be obtained by selecting the developer tools icon (wrench) in the top navigation bar of Tanzu Hub and choosing Copy raw token:



  • Network: Ensure your browser can reach the Tanzu Hub FQDN on port 443.

 

Connection Steps

  1. Access the Endpoint:

    Open your web browser and navigate to the following URL pattern: https://<YOUR-TANZU-HUB-FQDN>/hub/altair

    Note: Replace <YOUR-TANZU-HUB-FQDN> with the hostname configured during your Tanzu Hub installation (e.g., hub.example.com).

  2. Configure Authentication Headers

    Because Tanzu Hub is secure by default, you must provide your authentication token in the request header:


    • In the Altair interface, click the Set Headers icon:



    • Add a new header with the following key-value pair:
      1. Header Key: Authorization
      2. Header Value: Bearer <YOUR_TOKEN_HERE>



    • Click Save or Done.

  3. Verify the Connection

    1. In the URL bar within Altair (next to the POST method), ensure the API target is set to: https://<YOUR-TANZU-HUB-FQDN>/hub/graphql
    2. Click the Docs button on the right sidebar to verify that the schema loads successfully. If you see the documentation for types and queries, your connection is active.
      • NOTE: The schema can be downloaded to assist query creation after clicking the Docs button:




  4. Sample Query

     

    To test your connection, paste the following query into the editor window to list the spaces attached to your Hub:

     

    • GraphQL:

      query getSpaces(
        $filter: QueryFilter,
        $first: Int = 10,
        $after: String,
        $sort: [QuerySort!],
        $spaceEntityId: [EntityId!],
      ) {
        entityQuery {
          queryEntities(
            entityTypeConst: Tanzu_TAS_Space,
            entityId: $spaceEntityId,
            first: $first,
            after: $after,
            filter: $filter,
            sort: $sort,
          ) {
            totalCount
            pageInfo {
              hasNextPage
              endCursor
            }
            entities {
              name: entityName
              id: entityId
              entityType
              creationTime
              lastUpdateTime
              properties {
                name
                value
                type
              }
              organization: entitiesOut(entityType: "Tanzu.TAS.Organization") {
                entities {
                  name: entityName
                  id: entityId
                  entityType
                  foundation: entitiesOut(entityType: "Tanzu.TAS.Foundation") {
                    entities {
                      name: entityName
                      id: entityId
                      entityType
                    }
                  }
                }
              }
            }
          }
        }
      }

       

  5. Troubleshooting

    • 401 Unauthorized: Your token may have expired. Generate a new "raw token" from the developer tools menu in the Tanzu Hub UI.
    • Site Can't Be Reached: Ensure you are using https and that no firewall is blocking traffic to the Hub FQDN on port 443.
    • Intelligent Assist Support: If you need help generating complex GraphQL for programmatic use, you can ask Tanzu Intelligent Assist (TIA) directly within the UI (e.g., "Generate a GraphQL query for my Spring apps").