import { getGraphQLEnumValues , getDemographicsResolvers } from '../helpers' ; import { getEntity } from '../entities' ; import { RequestContext , SurveyConfig } from '../types' ; import { Filters } from '../filters' ; import { computeToolExperienceGraph , computeToolsCardinalityByUser , ToolExperienceId } from '../compute' ; import { useCache } from '../caching' ; const toolIds = getGraphQLEnumValues ( 'ToolID' ) ; const featureIds = getGraphQLEnumValues ( 'FeatureID' ) ; /**
 * Please maintain the same order as the one shown in the explorer,
 * it makes it easier to find a specific query and ensures consistency.
 */ export default { Survey : { surveyName : ( survey ) => { return survey . survey ; } , bracketWins : ( survey , { id , filters } ) => ( { survey , id , filters } ) , bracketMatchups : ( survey , { id , filters } ) => ( { survey , id , filters } ) , category : ( survey , { id } ) => ( { survey , id , happiness : ( { filters } ) => ( { survey , id , filters } ) , otherTools : ( { filters } ) => ( { survey , id , filters } ) } ) , demographics : ( survey ) => ( { participation : { survey } , ... getDemographicsResolvers ( survey ) } ) , environments : ( survey , { id , filters } ) => ( { survey , id , filters } ) , environments_ratings : ( survey , { id , filters } ) => ( { survey , id , filters } ) , feature : ( survey , { id } ) => ( { survey , id , experience : ( { filters } ) => ( { survey , id , filters } ) } ) , features : ( survey , { ids = featureIds } ) => ids . map ( id => ( { survey , id , experience : ( { filters } ) => ( { survey , id , filters } ) } ) ) , features_others : ( survey , { id , filters } ) => ( { survey , id , filters } ) , happiness : ( survey , { id , filters } ) => ( { survey , id , filters } ) , matrices : ( survey ) => ( { survey } ) , opinion : ( survey , { id , filters } ) => ( { survey , id , filters } ) , opinions_others : ( survey , { id , filters } ) => ( { survey , id , filters } ) , proficiency : ( survey , { id , filters } ) => ( { survey , id , filters } ) , resources : ( survey , { id , filters } ) => ( { survey , id , filters } ) , tool : async ( survey , { id } ) => ( { survey , id , entity : await getEntity ( { id } ) , experience : ( { filters } ) => ( { survey , id , filters } ) , experienceGraph : async ( { filters } , { db } ) => useCache ( computeToolExperienceGraph , db , [ survey , id , filters ] ) } ) , tools : async ( survey , { ids = toolIds } ) => ids . map ( async ( id ) => ( { survey , id , entity : await getEntity ( { id } ) , experience : ( { filters } ) => ( { survey , id , filters } ) , experienceGraph : async ( { filters } , { db } ) => useCache ( computeToolExperienceGraph , db , [ survey , id , filters ] ) } ) ) , tools_cardinality_by_user : ( survey , { year , ids , experienceId } , context ) => useCache ( computeToolsCardinalityByUser , context . db , [ survey , year , ids , experienceId ] ) , tools_others : ( survey , { id , filters } ) => ( { survey , id , filters } ) , tools_rankings : ( survey , { ids , filters } ) => ( { survey , ids , filters } ) , totals : ( survey ) => survey } } ;