Chamei algumas querys e funcionaram normalmente, mas quando vou chamar a query de pickupPoints ocorre Render Server - Error.
query:
query pickupPoints($page: int!, $perPage: int!) {
getPickupPoints(page: $page, perPage: $perPage) {
items{
name,
description,
address {
city,
country,
complement,
state,
street
},
isActive
}
}
}
código react:
import React from "react";
import { useQuery } from "react-apollo";
import GET_PICKUPS from './graphql/pickup-points.graphql'
const PickUpPoints = () => {
console.log('pickuppoints')
const getPickupPoints = useQuery(GET_PICKUPS, {
variables: {
page: 1,
perPage: 10,
},
})
return (
<p>render</p>
)
}
export default PickUpPoints
Erro: Error: Network error: Only public queries are allowed during server side rendering
Alguém sabe o que pode ser?
Estou tendo o mesmo tipo de problema, com outras consultas
@framework66 , veja se o seu problema diz respeito a falta de instalação da referencia ao graphl de pickupponts (se for esse que você está tentando consultar), a documentação da VTEX não orienta sobre a instalação desses endpoints, apenas informa como usar o graphql infelizmente. Acabei descobrindo pela tentativa e erro.
Para instalar por exemplo, no caso do pickuppoints,
- você vai na pasta onde está seu manifest.json e roda o comando VTEX install VTEX.admin-pickup-points@2.13.0 , que nem aparece no seu graphlIDE lá na VTEX.
- depois vai nas dependencias do seu manifest.json e adiciona a linha referente ao que vc instalou,por ex: “VTEX.admin-pickup-points” : “2.x”
- em seguida, na sua pasta onde tem o react e seu package.json, você roda um VTEX setup para ele baixar os types e lincar essa api como uma referencia nas dependencias;
- apaga o node modules
- agora roda o VTEX link que ele vai fazer o download das dependencias necessárias
I’m having the same issue with vtex.catalog-graphql@1.102.3, but it seems it doesn’t allow you to make private API calls on the server side. What’s the point of using GraphQL then if we can’t query APIs that would normally require a Key and Token, given the premise that GraphQL doesn’t expose sensitive data like that on the Front-End — yet we can’t even fetch a simple list of brands just because the Catalog API is locked down?
I’m also having the same problem and haven’t found a solution yet
Contributing here with something I discovered recently: GraphQL queries only work with SSR when they have the @cacheControl(scope: PUBLIC, maxAge: SHORT) directive
maxAge can have the following values: LONG, MEDIUM, or SHORT
Documentation on the subject, but which doesn’t directly address the SSR topic: GitHub - vtex-apps/graphql-example: A reference app implementing a VTEX IO service with GraphQL resolvers · GitHub