UNPKG

@leosprograms/vf-graphql-holochain

Version:

GraphQL schema bindings for the Holochain implementation of ValueFlows

33 lines (26 loc) 948 B
/** * Top-level queries relating to Plan * * @package: HoloREA * @since: 2019-05-27 */ import { DNAIdMappings, injectTypename, ReadParams } from '../types.js' import { mapZomeFn } from '../connection.js' import { Plan, PlanConnection, PlanResponse, } from '@leosprograms/vf-graphql' import { PagingParams } from '../resolvers/zomeSearchInputTypes.js' export default (dnaConfig: DNAIdMappings, conductorUri: string) => { const readOne = mapZomeFn<ReadParams, PlanResponse>(dnaConfig, conductorUri, 'combined', 'plan', 'get_plan') const readAll = mapZomeFn<PagingParams, PlanConnection>(dnaConfig, conductorUri, 'combined', 'indexing', 'read_all_plans') return { plan: injectTypename('Plan', async (root, args): Promise<Plan> => { return (await readOne({ address: args.id })).plan }), plans: async (root, args: PagingParams): Promise<PlanConnection> => { return await readAll(args) }, } }