You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I having some trouble to understand how to use this library when I want to make multiple fetch on getStaticProps (example) and return that data. I think Im not getting the correct result, because when I enter the page, the request appears on the XHR twice (one canceled, and the other with success), but it should not appear as I know.
Thanks
The text was updated successfully, but these errors were encountered:
hi,
this module is not designed to run multiple queries on getStaticProps, as it integrates together the query and the cache extraction. Nevertheless, if you pass the same apollo instance to the 2 fetch requests the cache should be populated. I suggest you to debug what is returned by the normalized cache
Tried getting onboard with this too, but ended up doing this instead:
import{InferGetServerSidePropsType}from'next'import{client}from'../config'import{ArticlesDocument,ArticlesQuery,ArticlesQueryVariables,}from'../middleware'exportconstgetServerSideProps=async()=>{constarticlesQueryResults=awaitclient.query<ArticlesQuery,ArticlesQueryVariables>({query: ArticlesDocument,})return{props: {
articlesQueryResults,},}}exportdefaultfunctionProjects({
articlesQueryResults,}: InferGetServerSidePropsType<typeofgetServerSideProps>){const{ data, error }=articlesQueryResults// do stuff with data or error, etc...}
To be honest a module that exports a typed client.query would be really handy to me, as I need the flexibility more.
Hiii,
I having some trouble to understand how to use this library when I want to make multiple fetch on
getStaticProps
(example) and return that data. I think Im not getting the correct result, because when I enter the page, the request appears on the XHR twice (one canceled, and the other with success), but it should not appear as I know.Thanks
The text was updated successfully, but these errors were encountered: