// @flow import gql from 'graphql-tag' import {getApi} from './__settings.js'; import {horariosGrupos} from './types/horariosgrupos' import {horarioMaestro} from './types/horariomaestro' import {horariosGruposUpdate} from './types/horariosgruposupdate' export const horariosApi = { // Queries gruposGetByGrupoId : function (grupoId:string){ return { select : async (selection:string):Promise =>{ const {data : {horariosGruposGetByGrupoId}} = await getApi().query({ query : gql` query horariosGruposGetByGrupoId($grupoId: ID!){ horariosGruposGetByGrupoId(grupoId: $grupoId){ ${selection} } } ` , variables : {grupoId}, }); return horariosGruposGetByGrupoId } } }, gruposGetById : function (id:string){ return { select : async (selection:string):Promise =>{ const {data : {horariosGruposGetById}} = await getApi().query({ query : gql` query horariosGruposGetById($id: ID!){ horariosGruposGetById(id: $id){ ${selection} } } ` , variables : {id}, }); return horariosGruposGetById } } }, maestrosGetByMaestroId : function (maestroId:string){ return { select : async (selection:string):Promise =>{ const {data : {horariosMaestrosGetByMaestroId}} = await getApi().query({ query : gql` query horariosMaestrosGetByMaestroId($maestroId: ID!){ horariosMaestrosGetByMaestroId(maestroId: $maestroId){ ${selection} } } ` , variables : {maestroId}, }); return horariosMaestrosGetByMaestroId } } }, // Mutations gruposUpdate : function (id:string,input:horariosGruposUpdate?){ return { select : async (selection:string):Promise => { const {data : {horariosGruposUpdate}} = getApi().mutate({ mutation: gql` mutation horariosGruposUpdate($id: ID!,$input: horariosGruposUpdate){ horariosGruposUpdate(id: $id,input: $input){ ${selection} } } ` , variables : {id,input}, }); return horariosGruposUpdate } } }, }