// @flow import gql from 'graphql-tag' import {getApi} from './__settings.js'; import {justificaciones} from './types/justificaciones' import {innerJustificaciones} from './types/innerjustificaciones' import {justificacionesGenerales} from './types/justificacionesgenerales' import {justificacionesInput} from './types/justificacionesinput' import {justificacionesGeneralesInput} from './types/justificacionesgeneralesinput' export const justificacionesApi = { // Queries getAll : function (general:boolean?){ return { select : async (selection:string):Promise> =>{ const {data : {justificacionesGetAll}} = await getApi().query({ query : gql` query justificacionesGetAll($general: Boolean){ justificacionesGetAll(general: $general){ ${selection} } } ` , variables : {general}, }); return justificacionesGetAll } } }, getById : function (id:string){ return { select : async (selection:string):Promise =>{ const {data : {justificacionesGetById}} = await getApi().query({ query : gql` query justificacionesGetById($id: ID!){ justificacionesGetById(id: $id){ ${selection} } } ` , variables : {id}, }); return justificacionesGetById } } }, generalesGetByGrupoId : function (grupoId:string,cicloEscolarId:string?,periodo:number?){ return { select : async (selection:string):Promise> =>{ const {data : {justificacionesGeneralesGetByGrupoId}} = await getApi().query({ query : gql` query justificacionesGeneralesGetByGrupoId($grupoId: ID!,$cicloEscolarId: ID,$periodo: Int){ justificacionesGeneralesGetByGrupoId(grupoId: $grupoId,cicloEscolarId: $cicloEscolarId,periodo: $periodo){ ${selection} } } ` , variables : {grupoId,cicloEscolarId,periodo}, }); return justificacionesGeneralesGetByGrupoId } } }, generalesGetByMaestroGrupoId : function (maestroGrupoId:string,cicloEscolarId:string?,periodo:number?){ return { select : async (selection:string):Promise> =>{ const {data : {justificacionesGeneralesGetByMaestroGrupoId}} = await getApi().query({ query : gql` query justificacionesGeneralesGetByMaestroGrupoId($maestroGrupoId: ID!,$cicloEscolarId: ID,$periodo: Int){ justificacionesGeneralesGetByMaestroGrupoId(maestroGrupoId: $maestroGrupoId,cicloEscolarId: $cicloEscolarId,periodo: $periodo){ ${selection} } } ` , variables : {maestroGrupoId,cicloEscolarId,periodo}, }); return justificacionesGeneralesGetByMaestroGrupoId } } }, // Mutations insert : function (input:justificacionesInput){ return { select : async (selection:string):Promise => { const {data : {justificacionesInsert}} = getApi().mutate({ mutation: gql` mutation justificacionesInsert($input: justificacionesInput!){ justificacionesInsert(input: $input){ ${selection} } } ` , variables : {input}, }); return justificacionesInsert } } }, generalesInsert : function (maestroGrupoId:string,periodo:number,input:justificacionesGeneralesInput?){ return { select : async (selection:string):Promise => { const {data : {justificacionesGeneralesInsert}} = getApi().mutate({ mutation: gql` mutation justificacionesGeneralesInsert($maestroGrupoId: ID!,$periodo: Int!,$input: justificacionesGeneralesInput){ justificacionesGeneralesInsert(maestroGrupoId: $maestroGrupoId,periodo: $periodo,input: $input){ ${selection} } } ` , variables : {maestroGrupoId,periodo,input}, }); return justificacionesGeneralesInsert } } }, }