... | ... | @@ -64,7 +64,7 @@ _Neglecting to include the secured attribute in an API function definition will |
|
|
|
|
|
Prior to April 2020, the current API routing scheme was simple but disorganized due to all API routes living in the `ModuleConfig` for the `v1` module. For instance, the API endpoint to list all available seasons using the `seasons` handler with the `list` function is:
|
|
|
|
|
|
```.route(:) "/seasons/list"
|
|
|
```.route(:"/seasons/list" )
|
|
|
.withAction( {
|
|
|
GET = "list"
|
|
|
} )
|
... | ... | @@ -260,16 +260,18 @@ Resolvers conform to the following schema: |
|
|
entity.where( "someField", "=", args.value )
|
|
|
}
|
|
|
},
|
|
|
"resolveSelect" : ( entity, args, $args ) => {
|
|
|
"selectable" : { // if we can display an output field, the relevant resolver goes here
|
|
|
"resolveSelect" : ( entity, args, $args ) => {
|
|
|
// lambda function adding output columns to the entity and (optionally) registering a callback on the results to modify that output
|
|
|
entity.addSelect( "someField" )
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### Conventions
|
|
|
|
|
|
`$args` in the `resolveWhere` and `resolveSelect` is an internal processing store (not unlike `prc` vs. `rc` in Coldbox) that is consistent across resolvers. It handles pre- and post-processing (e.g. modifying the output of a resolveSelect that has fetched a database column where the value to display is some mutated value based on that column)
|
|
|
`$args` in the `resolveWhere` and `resolveSelect` is an internal processing store (not unlike `prc` vs. `rc` in Coldbox) that is consistent across resolvers. It handles pre- and post-processing (e.g. modifying the output of a resolveSelect that has fetched a database column where the value to display is some mutated value based on that column)
|
|
|
|
|
|
### Nullable Boolean Where Resolver
|
|
|
|
... | ... | @@ -287,15 +289,18 @@ Resolvers conform to the following schema: |
|
|
unsafeRaw_columnNameOrExpr = "birthCertificate",
|
|
|
value = args.value
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
"resolveSelect" : ( entity, args, $args ) => {
|
|
|
entity.addSelect( "birthCertificate" );
|
|
|
$args.ctx.registerOnLoadCallback( ( array results ) => {
|
|
|
for ( var row in results ) {
|
|
|
row.birthCertificate = yesNoFormat( row.birthCertificate );
|
|
|
}
|
|
|
})
|
|
|
"selectable" : {
|
|
|
"label" : "Birth Certificate",
|
|
|
"resolveSelect" : ( entity, args, $args ) => {
|
|
|
entity.addSelect( "birthCertificate" );
|
|
|
$args.ctx.registerOnLoadCallback( ( array results ) => {
|
|
|
for ( var row in results ) {
|
|
|
row.birthCertificate = yesNoFormat( row.birthCertificate );
|
|
|
}
|
|
|
} )
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
``` |
|
|
\ No newline at end of file |