UNPKG

@leosprograms/vf-graphql-holochain

Version:

GraphQL schema bindings for the Holochain implementation of ValueFlows

51 lines (41 loc) 1.4 kB
/** * Intent mutations * * @package: HoloREA * @since: 2019-08-31 */ import { ByRevision, DNAIdMappings } from '../types.js' import { mapZomeFn } from '../connection.js' import { deleteHandler } from './' import { IntentCreateParams, IntentUpdateParams, IntentResponse, } from '@leosprograms/vf-graphql' export interface CreateArgs { intent: IntentCreateParams, } export type createHandler = (root: any, args: CreateArgs) => Promise<IntentResponse> export interface UpdateArgs { intent: IntentUpdateParams, } export type updateHandler = (root: any, args: UpdateArgs) => Promise<IntentResponse> export default (dnaConfig: DNAIdMappings, conductorUri: string) => { const runCreate = mapZomeFn<CreateArgs, IntentResponse>(dnaConfig, conductorUri, 'combined', 'intent', 'create_intent') const runUpdate = mapZomeFn<UpdateArgs, IntentResponse>(dnaConfig, conductorUri, 'combined', 'intent', 'update_intent') const runDelete = mapZomeFn<ByRevision, boolean>(dnaConfig, conductorUri, 'combined', 'intent', 'delete_intent') const createIntent: createHandler = async (root, args) => { return runCreate(args) } const updateIntent: updateHandler = async (root, args) => { return runUpdate(args) } const deleteIntent: deleteHandler = async (root, args) => { return runDelete(args) } return { createIntent, updateIntent, deleteIntent, } }