UNPKG

@leosprograms/vf-graphql-holochain

Version:

GraphQL schema bindings for the Holochain implementation of ValueFlows

29 lines (24 loc) 1 kB
/** * Top-level queries relating to Fulfillments * * @package: HoloREA * @since: 2019-08-28 */ import { DNAIdMappings, ReadParams } from '../types.js' import { mapZomeFn } from '../connection.js' import { Fulfillment, FulfillmentConnection, FulfillmentResponse, } from '@leosprograms/vf-graphql' import { PagingParams } from '../resolvers/zomeSearchInputTypes.js' export default (dnaConfig: DNAIdMappings, conductorUri: string) => { const readOne = mapZomeFn<ReadParams, FulfillmentResponse>(dnaConfig, conductorUri, 'combined', 'fulfillment', 'get_fulfillment') const readAll = mapZomeFn<PagingParams, FulfillmentConnection>(dnaConfig, conductorUri, 'combined', 'indexing', 'read_all_fulfillments') return { fulfillment: async (root, args): Promise<Fulfillment> => { return (await (await readOne)({ address: args.id })).fulfillment }, fulfillments: async (root, args: PagingParams): Promise<FulfillmentConnection> => { return await readAll(args) }, } }