digitalsimboja
04/08/2022, 1:22 PMquery {
postCollection {
edges {
node {
id
description
}
}
}
}
// Query for the data (React)
const [result, reexecuteQuery] = useQuery({
query: PostsQuery,
})
// Read the result
const { data, fetching, error } = result
if (!data) {
// If there is a server error, you might want to
// throw an error instead of returning so that the cache is not updated
// until the next successful request.
throw new Error(Failed to fetch posts, received status ${error})
}
// If the request was successful, return the posts
// and revalidate every 10 seconds.
return {
props: {
posts,
},
revalidate: 10,
}
}