// @flow import gql from 'graphql-tag' import {getApi} from './__settings.js'; import {clubes} from './types/clubes' import {clubesInput} from './types/clubesinput' export const clubesApi = { // Queries getById : function (id:string){ return { select : async (selection:string):Promise =>{ const {data : {clubesGetById}} = await getApi().query({ query : gql` query clubesGetById($id: ID!){ clubesGetById(id: $id){ ${selection} } } ` , variables : {id}, }); return clubesGetById } } }, getByMaestroId : function (maestroId:string,escuelaId:string){ return { select : async (selection:string):Promise> =>{ const {data : {clubesGetByMaestroId}} = await getApi().query({ query : gql` query clubesGetByMaestroId($maestroId: ID!,$escuelaId: ID!){ clubesGetByMaestroId(maestroId: $maestroId,escuelaId: $escuelaId){ ${selection} } } ` , variables : {maestroId,escuelaId}, }); return clubesGetByMaestroId } } }, // Mutations insert : function (input:clubesInput){ return { select : async (selection:string):Promise => { const {data : {clubesInsert}} = getApi().mutate({ mutation: gql` mutation clubesInsert($input: clubesInput!){ clubesInsert(input: $input){ ${selection} } } ` , variables : {input}, }); return clubesInsert } } }, }