@leosprograms/vf-graphql-holochain
Version:
GraphQL schema bindings for the Holochain implementation of ValueFlows
52 lines (42 loc) • 1.62 kB
text/typescript
/**
* Recipe Process mutations
*
* @package: HoloREA
* @since: 2019-08-31
*/
import { ByRevision, DNAIdMappings } from '../types.js'
import { mapZomeFn } from '../connection.js'
import { deleteHandler } from './'
import {
RecipeProcessCreateParams,
RecipeProcessUpdateParams,
RecipeProcessResponse,
} from '@leosprograms/vf-graphql'
export interface CreateArgs {
recipeProcess: RecipeProcessCreateParams,
}
export type createHandler = (root: any, args: CreateArgs) => Promise<RecipeProcessResponse>
export interface UpdateArgs {
recipeProcess: RecipeProcessUpdateParams,
}
export type updateHandler = (root: any, args: UpdateArgs) => Promise<RecipeProcessResponse>
export default (dnaConfig: DNAIdMappings, conductorUri: string) => {
const runCreate = mapZomeFn<CreateArgs, RecipeProcessResponse>(dnaConfig, conductorUri, 'combined', 'recipe_process', 'create_recipe_process')
const runUpdate = mapZomeFn<UpdateArgs, RecipeProcessResponse>(dnaConfig, conductorUri, 'combined', 'recipe_process', 'update_recipe_process')
const runDelete = mapZomeFn<ByRevision, boolean>(dnaConfig, conductorUri, 'combined', 'recipe_process', 'delete_recipe_process')
const createRecipeProcess: createHandler = async (root, args) => {
console.log("createRecipeProcess **", args)
return runCreate(args)
}
const updateRecipeProcess: updateHandler = async (root, args) => {
return runUpdate(args)
}
const deleteRecipeProcess: deleteHandler = async (root, args) => {
return runDelete(args)
}
return {
createRecipeProcess,
updateRecipeProcess,
deleteRecipeProcess,
}
}