Domain configuration
Operations
Operation configuration

Operation Configuration

OperationConfig

OptionTypeDefaultDescription
inputstring |
string[] |
{[name:string]:true | OperationInputConfig}
Definition of the input type for the Mutation
resultstring |
string[] |
TypeConfig
Definition of the result type for the Mutation
descriptionstringDescription of the Mutation in the schema
resultTypeNamestringOperationNameResultname of the result type in the schema
returnTypeNamestringOperationNameReturnname of the return type in the schema this includes the result, the ValidationViolation and the _Dispositions
onContextCreate(ctx:OperationContext) => voidcallback at context creation, giving the opportunity to add properties to the context
dispostionsOperationFn<void>based on input definitioncustom implementation to determine the attribute dispositions
beforeValidationOperationCallback<boolean>callback before any input is validated, giving the opportunity to manipulate the input
validationConfigSource<void>based on input definitionvalidation of all input attributes
beforeSaveOperationCallback<boolean>callback before any input is saved to the DataStore after successful validation, giving the opportunity to manipulate the input
saveboolean | OperationFn<boolean>based on input definitionsaving input as entity items to the DataStore
afterSaveOperationCallback<boolean>callback after any input is saved to the DataStore
buildResultOperationFn<boolean>based on result definitionbuilding the data type for the mutation's result
afterBuildResultOperationCallback<void>callback after the result was built; giving the opportunity to manipulate the result

Operation Input

While the input for an entity mutation is a plain object, the input of an operation can nested and as complex as your domain requires. For details please refer to Input Configuration

ConfigDescription
EntityNameany string value is resolved as { entity: entityName, attributes: true} meaning the input is exact the input of the referenced entity
{ EntityName: true}any of this items is resolved as { entity: entityName, attributes: true} meaning the input is exact the input of the referenced entity
Map of OperationInputConfigYou can configure a complex, dynamically evaluated and validated input types

Entity name

The most simple input (and result) definition would be referencing an entity. This operation would behave very similar to the createCar mutation. It takes a car input, saves it and returns it as result.

entity:
  Car:
    attributes:
      brand: String!
      licence: String!
operation:
  RentCar:
    input: Car
    result: Car

In this example the GraphQL schema mutation type would look like this:

'RentCar(car: RentCarInputCar): RentCarReturn'

The input type RentCarInputCar looks very much like the input type for the update mutation of the Car entity.

input RentCarInputCar {
  id: ID
  brand: String
  licence: String
}

If you have more than one you can use the entity name as key of the input configuration.

entity:
  Car:
    attributes:
      brand: String!
      licence: String!
operation:
  RentCar:
    input: 
      Car: 
        entity: Car
    result: Car

The GraphQL schema mutation type would now look like this:

'RentCar(car: RentCarInputCar): RentCarReturn'

Operation Result

{ result: string | string[] | TypeConfig }

Config valueDescription
stringentity
string[]list of entities
TypeConfiga custom type configuration

Besides the inputDispositions and validationViolations an operation should return the result of the business logic that is executed after any input was successfully validated.

The result configuration simply declares the type of that return value. It can either be an entity, a scalar or any (non-input) type from the DomainGraph.

Obviously the business logic (mainly the buildResult implementation) must set a value in the operations result that matches this definition.