Feature request: Add an option to return both query result and apollo cache.
kevineinarsson opened this issue · 3 comments
Hello! With Next.js 10, it is possible to set a property in the return object of getStaticProps that shows a 404 page with correct headers etc. This is done by setting the notFound property to true.
Example:
export function getStaticProps() {
return {
// returns the default 404 page with a status code of 404
notFound: true
}
}
To be able to easily check if we get any data, it would be nice to see the query result, and if it exists return the extracted apollo cache.
Is this something that is in scope for this library?
hi, good point, this plugin already provides the option to return the query result (returnRawQuery
config or the last boolean parameter in the getServerPage
function).
I also added the error object into the props in case you prefer to return the normalized apollo cache
Thanks for the update and quick reply!! 🎉
In my case, the issues still is there unfortuntately... My API does not send any erorrs when it doesn't find the entity I'm querying, the query is OK but the data.<GraphqlType>
object in the query result is null.
I could either solve this on my end with a link that creates an error if data is empty, or it could be solved with having a flag in this library to be "includeRawQuery" instead of "returnRawQuery"
Thoughts?
ok understood, so something like
const {apolloState, data, error} = getServerPage()
I guess we can simply return the 3 props all the time
I understand you'd like to use it in a way similar to this https://github.com/correttojs/graphql-codegen-apollo-next-ssr/pull/30/files#diff-7a655441e1d799a08d264cd8740e1d6019fe27a221fcfa64eee089a84d8a5992R25