// @flow import gql from 'graphql-tag' import {getApi} from './__settings.js'; import {estados} from './types/estados' import {estadoInput} from './types/estadoinput' export const estadosApi = { // Queries getAll : function (){ return { select : async (selection:string):Promise> =>{ const {data : {estadosGetAll}} = await getApi().query({ query : gql` query estadosGetAll{ estadosGetAll{ ${selection} } } ` , variables : {}, }); return estadosGetAll } } }, getById : function (id:string){ return { select : async (selection:string):Promise =>{ const {data : {estadosGetById}} = await getApi().query({ query : gql` query estadosGetById($id: ID!){ estadosGetById(id: $id){ ${selection} } } ` , variables : {id}, }); return estadosGetById } } }, // Mutations insert : function (input:estadoInput){ return { select : async (selection:string):Promise => { const {data : {estadosInsert}} = getApi().mutate({ mutation: gql` mutation estadosInsert($input: estadoInput!){ estadosInsert(input: $input){ ${selection} } } ` , variables : {input}, }); return estadosInsert } } }, }