async def gen_delete_pent_dynamic( context: PentContext, pent_cls_name: str, payload_cls_name: str, obj_id: UUID ) -> PentMutationPayload: pent_cls = context.cls_from_name(pent_cls_name) payload_cls = context.cls_from_name(payload_cls_name) deleted_id = await delete_pent(context, pent_cls, obj_id) return cast(PentMutationPayload, payload_cls(deleted_id))
async def gen_create_pent_dynamic( context: PentContext, pent_cls_name: str, data_cls_name: str, payload_cls_name: str, data: PentMutationData ) -> PentMutationPayload: data_cls = context.cls_from_name(data_cls_name) check.isinst(data, data_cls) pent_cls = context.cls_from_name(pent_cls_name) payload_cls = context.cls_from_name(payload_cls_name) out_pent = await create_pent(context, pent_cls, data) return cast(PentMutationPayload, payload_cls(out_pent))
async def mutation_resolver(obj: Any, args: Dict[str, Any], context: PentContext, *_: Any) -> Any: args = process_args(args) pent_data_cls = context.cls_from_name(pent_data_cls_name) pent_data = pent_data_cls(**args['data']) args['data'] = pent_data prop = getattr(obj, python_name) check.invariant(callable(prop), 'must be async function') return await prop(**args)
def mem_context(): provider_to_report = KvetchMemEdgeDefinition( edge_name='provider_to_report', edge_id=93843948, from_id_attr='provider_id', ) index = KvetchMemIndexDefinition( index_name='provider_number_index', indexed_type_id=100000, # Provider indexed_attr='provider') shard = KvetchMemShard() kvetch = Kvetch(shards=[shard], edges=[provider_to_report], indexes=[index]) return PentContext(kvetch=kvetch, config=get_hcris_config())
def get_pent_context(kvetch): param_check(kvetch, Kvetch, 'kvetch') return PentContext( kvetch=kvetch, config=get_hcris_config(), )
async def gen_browse_pents_dynamic( context: PentContext, after: UUID, first: int, out_cls_name: str ) -> List[Pent]: out_cls = context.cls_from_name(out_cls_name) pents = await out_cls.gen_browse(context, after, first) return cast(List[Pent], pents)
async def gen_pent_dynamic(context: PentContext, out_cls_name: str, obj_id: UUID) -> Pent: out_cls = context.cls_from_name(out_cls_name) pent = await out_cls.gen(context, obj_id) return cast(Pent, pent)