Fetching user's available customers
Fetch multiple customers linked to a user via GraphQL, using the availableCustomers query field with optional pagination and sorting.
Typically, a user is associated with a single Visma.net customer. However, it is possible that one user is linked to multipled customers. Business NXT GraphQL allows to fetch all these customers. The list of customers linked to the authenticated user is available with a special field under the Query
type. This field is called availableCustomers
. It is similar to the connection types seen so far, except that the pageInfo
field is missing.
Here is a query example:
Query
{
availableCustomers
{
totalCount
items
{
name
vismaNetCustomerId
}
}
}
Result
{
"data": {
"availableCustomers": {
"totalCount": 1,
"items": [
{
"name": "Test Customer for Business NXT",
"vismaNetCustomerId": 1234567
}
]
}
}
}
The availableCustomers
field has several optional arguments:
- an argument called
first
that indicates the number of elements to be fetched from the top of the customers list - an argument called
last
that indicates the number of elements to be fetched from the back of the customers list; if bothfirst
andlast
are present,first
is used andlast
is ignored - an argument called
sortOrder
that defines the sorting order of the result