https://supabase.com/ logo
Hello guys, How could I implement the Graphql quer...
# off-topic
d
Hello guys, How could I implement the Graphql query? I am currently doing this: export async function getStaticProps() { // If this request throws an uncaught error, Next.js will // not invalidate the currently shown page and // retry getStaticProps on the next request. // Prepare our GraphQL query const PostsQuery =
Copy code
query {
  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, } }