Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

243
Views
Cómo consultar el endpint de graphql desde un componente de reacción basado en clase

El producto de carga es tal vez lo llamamos gancho cuyo propósito de la vida es obtener los datos de un backend de graphql

Así es como LUCE LOAD_PRODUCT

 import { gql } from '@apollo/client' export const LOAD_PRODUCTS = gql` query{ categories { name products { id, name, inStock, gallery, category } } } ` import React, { Component } from 'react' import { useQuery,gql } from '@apollo/client' import { LOAD_PRODUCTS } from '../../graphql/productAction' export class ProductListing extends Component { constructor(){ super(); const {error,loading,data} = useQuery() } render() { return ( <div>ProductListing</div> ) } } export default ProductListing

por ahora solo quiero activar el gancho de usuario de carga y guardar establecer los datos en el estado diferente debe haber un método para hacer esto busco en google pero nada ayuda simplemente no puedo usar el método fetch para obtener el resultado

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

También puede consultar un punto final de graphql mediante el componente Query o el HOC . Pero tenga en cuenta que, dado que los componentes basados en clases se consideran heredados, ya no reciben ninguna actualización.

Usando el componente Consulta:

 import { Query } from '@apollo/client/react/components'; export class ProductListing extends Component { render() { return ( <Query query={LOAD_PRODUCTS}> {({data}) => <div>Render data here ...</div>} </Query> ) } }

Usando el HOC:

 import { graphql } from '@apollo/client/react/hoc'; class ProductListing extends Component { render() { const data = this.props.data; return <div>Render data here ...</div>; } } export default graphql(LOAD_PRODUCTS)(ProductListing);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!