Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 1.57 KB

resolver.md

File metadata and controls

61 lines (45 loc) · 1.57 KB
id title
resolver
Resolver

:::info TypeScript Support

A view model resolver object has an associated TypeScript type:

  • Type Name - ViewModelResolver
  • Package - @resolve-js/core

:::

A view model resolver function has the following structure:

async(api, query, context) => {
    ...
    return {
        data, // Built view model data.
        meta: {  // Metadata about the resolver execution results.
          cursor, // The data cursor used to traverse the events included into the query result set.
          eventTypes, // The list of event types available to the client.
          aggregateIds, // List of aggregate IDs available to the client.
        }
    }
}

API

The API argument is an object that contains the following API:

Function Name Description
buildViewModel Runs a projection for the view model

Query

The query argument is an object with the following fields:

Field Name Description
aggregateIds An array of aggregate IDs.
aggregateArgs An object that contains arguments attached to the query.

Context

The context argument is an object of the following structure:

{
  jwt, // Optional. The JSON web token attached to the request.
  viewModel: {
    name, // The name of the view model.
    eventTypes // The event types available to the view model.
  }
}