Why Does the Organization GraphQL API Return Only 10 Accounts When There Are More in the Tenant?
search cancel

Why Does the Organization GraphQL API Return Only 10 Accounts When There Are More in the Tenant?

book

Article ID: 284042

calendar_today

Updated On:

Products

CloudHealth

Issue/Introduction

This is due to the query not specifying the number of organizations or AWS accounts to fetch.


{
organizations {
edges {
node {
id
name
description
parentOrganizationCRN
defaultOrganization
flexOrg
awsAccounts {
edges {
node {
id
name
}
}
}
}
}
}
}

The query above defaults to the GraphQL server's predefined limit (which is often set for performance reasons).  If the server's default limit is 10, for instance, then this query will only fetch the first 10 organizations and their respective AWS accounts.

In order to get more than 10 orgs and 10 accounts per org, the pagination can be adjusted:

{ 
organizations(first: 100) {
edges {
node {
id
name
description
parentOrganizationCRN
defaultOrganization
flexOrg
awsAccounts (first: 100){
edges {
node {
id
name
}
}
}
}
}
}
}

The above adjustment to the script will result in the first 100 lines all the way out to number of accounts / orgs as required.