Wait useQuery in server #16321
Unanswered
PetrVasilev
asked this question in
Help
Replies: 1 comment
-
instead of using the hook inside of your component on the server, what you might want to try is creating an instance of the client inside of const getStaticProps = async () => {
const client = createApolloClient();
client.query(/* Same parameters as useQuery */);
return {
props: {
initialApolloState: client.cache.extract(),
},
revalidate: 1,
}
} then in your export default function App({ Component, pageProps }) {
const apolloClient = useApollo(pageProps.initialApolloState)
return (
<ApolloProvider client={apolloClient}>
<Component {...pageProps} />
</ApolloProvider>
)
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I did exactly like in with-apollo example. But useQuery for getting my user info is working only in client side. How i can wait this query?
Beta Was this translation helpful? Give feedback.
All reactions