@@ -14,6 +14,8 @@ import {
1414 Newspaper as INewspaper ,
1515 Partner as IPartner ,
1616} from '../models/generated/schemas'
17+ import { FacetWithLabel } from '../models/generated/shared'
18+ import { ImageTypeValueLookup } from '../services/images/images.class'
1719export type CachedFacetType =
1820 | 'newspaper'
1921 | 'topic'
@@ -24,7 +26,11 @@ export type CachedFacetType =
2426 | 'partner'
2527 | 'nag'
2628 | 'organisation'
27- export type CachedFacetTypes = ITopic | IYear | IEntity | ICollection | INewspaper | IPartner
29+ | 'imageVisualContent'
30+ | 'imageTechnique'
31+ | 'imageCommunicationGoal'
32+ | 'imageContentType'
33+ export type CachedFacetTypes = ITopic | IYear | IEntity | ICollection | INewspaper | IPartner | FacetWithLabel
2834
2935export type IResolver < T > = ( id : string ) => Promise < T | undefined >
3036
@@ -38,6 +44,10 @@ export type ICachedResolvers = {
3844 partner : IResolver < IPartner >
3945 nag : IResolver < IEntity >
4046 organisation : IResolver < IEntity >
47+ imageVisualContent : IResolver < FacetWithLabel >
48+ imageTechnique : IResolver < FacetWithLabel >
49+ imageCommunicationGoal : IResolver < FacetWithLabel >
50+ imageContentType : IResolver < FacetWithLabel >
4151}
4252
4353// Record<CachedFacetType, IResolver<T>>
@@ -95,6 +105,14 @@ const getNewspaperResolver = (app: ImpressoApplication): IResolver<NewspaperInte
95105 }
96106}
97107
108+ const imageTypeResolver = async ( id : string , field : keyof typeof ImageTypeValueLookup ) => {
109+ const lookup = ImageTypeValueLookup [ field ]
110+ return {
111+ id,
112+ label : lookup [ id ] ?? id ,
113+ } satisfies FacetWithLabel
114+ }
115+
98116export const buildResolvers = ( app : ImpressoApplication ) : ICachedResolvers => {
99117 return {
100118 collection : getCollectionResolver ( app ) ,
@@ -106,5 +124,9 @@ export const buildResolvers = (app: ImpressoApplication): ICachedResolvers => {
106124 partner : getPartnerResolver ( app ) ,
107125 nag : ( id : string ) => entityResolver ( id , 'nag' ) ,
108126 organisation : ( id : string ) => entityResolver ( id , 'organisation' ) ,
127+ imageVisualContent : ( id : string ) => imageTypeResolver ( id , 'type_l0_tp' ) ,
128+ imageTechnique : ( id : string ) => imageTypeResolver ( id , 'type_l1_tp' ) ,
129+ imageCommunicationGoal : ( id : string ) => imageTypeResolver ( id , 'type_l2_tp' ) ,
130+ imageContentType : ( id : string ) => imageTypeResolver ( id , 'type_l3_tp' ) ,
109131 }
110132}
0 commit comments