Please note that DTOs are no longer utilized for query operations in our GraphQL setup for Sage Active Public API V2.

This change simplifies the data retrieval process by directly referencing the actual resource names in fragments instead of using DTOs.

See more details below in the Queries chapter.

When working with GraphQL, specifically Hot Chocolate, in the context of Sage Active Public API V2, it’s essential to understand the role and naming convention of Data Transfer Objects (DTOs).
These DTOs facilitate data exchange between client and server and play a critical role in mutations.

General Naming Convention

For each resource, we use a specific naming pattern for the associated DTOs:

For instance, for a resource named AccountingAccount:

The Role of DTOs in Mutations

Create Mutation Example

For creating a new resource, you will use the CreateGLDtoInput DTO. The following mutation creates a new Journal Type:

mutation ($values: JournalTypeCreateGLDtoInput!) {  
  createJournalType (input: $values) {
    id
  }
}

Update Mutation Example

For updating an existing resource, you’ll use the UpdateGLDtoInput DTO:

mutation ($values: JournalTypeUpdateGLDtoInput!) {  
  updateJournalType (input: $values) {
    id
  }
}

Delete Mutation Example

For deleting an existing resource, you’ll use the DeleteGLDtoInput DTO:

mutation ($values:AccountingAccountDeleteGLDtoInput!) {
    deleteAccountingAccount(input: $values) {
    id
  }
}

The Role of DTOs in Queries

In our GraphQL setup for Sage Active Public API V2, DTOs are no longer used in query operations.
Instead, replace DTO references in fragments with the actual resource name to streamline data retrieval.

When defining fragments that previously relied on DTOs, you should now use the actual resource name.
The resource name in the fragment must be in singular form with the first letter capitalized.

For example:

Here’s how you should reference resources in your queries:

Query with Fragment Example

The following query retrieves a list of users along with specific user properties defined in a fragment: