I would like to perform a graphql mutation in getServerSideProps
. I am using graphql-codegen to generate code from my graphql call. The code I use to perform my mutation is:
const [getTokenMutation, _] = useGetTokenMutation()
const token = await getTokenMutation({
When I move the working code from the function body to getServerSideProps
I get the error: Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons ...
To solve this I looked in to the graphql-codegen-apollo-next-ssr
plugin for graphql-codegen. Unfortunately this only is generating code for the queries I have defined, not for the mutations.
How can I perform my mutation from getServerSideProps?