GraphQL API
The Smart WebAPI GraphQL endpoint is implemented using Microsoft Data API builder (DAB). The GraphQL API exposes all DTO entities made available by the integration services; see Swagger for the list of integration services. The available entities are not determined by a separately published schema. DAB provides the GraphQL layer and translates queries into operations against the underlying data source. Field names and relationships must match the GraphQL contract exposed by the endpoint.
Endpoint and request
Send GraphQL requests using POST to:
https://tse.smart-api.teamsystem.cloud/core/graphql
The request body is JSON with a query property. If the query declares variables, pass their values separately in the variables property. For example:
POST https://tse.smart-api.teamsystem.cloud/core/graphql
Authorization: Bearer <access-token>
Authorization-Scope: <environment>
Content-Type: application/json
Accept: application/json
{
"query": "query { documentoTestataMGs(first: 5) { items { Id DocumentNumber } } }"
}
Use the Bearer token obtained during the login flow. As with the other WebAPI endpoints, provide Authorization-Scope with the environment value required by the service. For details, see the authentication guide. Do not embed tokens in the query or expose them in client-side logs.
Query behavior
- A GraphQL operation selects only the entities and fields needed by the client. Field names and relationships must match the schema exposed by the endpoint.
- Use GraphQL variables for dynamic values, such as the
$idparameter in the example, and provide them in the JSONvariablesobject. This avoids building query strings by concatenating user input. - Aliases rename fields in the response; they do not change the underlying entity or field. For example,
Righe:andTestata:name the two result fields, whileNumDoc:renamesDocumentIdinside the grouped result. filterrestricts results,orderBydefines their order, andfirstlimits the number of records returned. See the DAB documentation for filtering, sorting, and page size.- When a paginated result includes
hasNextPage: true, use itsendCursoras theafterargument in the next request. See GraphQL pagination. - A response contains
datawhen results are available and may containerrorswhen one or more fields fail. Checkerrorsin addition to the HTTP status; a successful HTTP transport alone does not guarantee that every field resolved successfully.
Example: grouped order lines and document headers
The query below groups order lines by document and item, and retrieves up to five document headers in the selected date range.
query RigheRaggruppatePerDocumentoEArticolo($id: Decimal!) {
Righe: documentoCorpoMGs(filter: { NetAmount: { gt: $id } }) {
groupBy(fields: [DocumentId, ItemCode]) {
records: fields {
NumDoc: DocumentId
Articolo: ItemCode
}
aggregations {
quantitaTotale: count(field: DO30_ID)
}
}
}
Testata: documentoTestataMGs(
first: 5
orderBy: { DocumentDate: DESC }
filter: { DocumentDate: { gte: "2021-01-01T00:00:00Z", lte: "2026-09-21T23:59:59Z" } }
) {
items {
Id
DocumentNumber
DocumentDate
DocumentoTestataMG_CustomerSupplierCO {
CustomerSupplierCO_GeneralMasterDataFKCO {
LegalName
VatNumber
}
}
}
hasNextPage
endCursor
}
}
Pass a value for $id in the request body, for example "variables": { "id": 100 }, using a value compatible with the Decimal scalar. In the Testata result, hasNextPage and endCursor support retrieval of subsequent pages.
Note:
count(field: DO30_ID)counts matching values; the aliasquantitaTotaledoes not make it a quantity sum. To calculate a total quantity, usesumon the appropriate quantity field if that field and aggregation are available in the published schema. DAB aggregation support depends on the database provider: see GraphQL aggregation and DAB feature availability. VerifygroupBy, aggregation fields, and relationships against the schema of the target environment.