Last active
December 17, 2020 10:17
-
-
Save velotiotech/32bbaeb94a65912668bfd0a20deef083 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import { GetBlogPost } from "./__generated__/GetBlogPost.graphql"; | |
import { useLazyLoadQuery } from "react-relay/hooks"; | |
import { BlogPostHead } from "./BlogPostHead"; | |
import { BlogPostBody } from "./BlogPostBody"; | |
import { graphql } from "react-relay"; | |
interface BlogPostProps { | |
postId: string; | |
} | |
export const BlogPost = ({ postId }: BlogPostProps) => { | |
const { blogPostById } = useLazyLoadQuery<GetBlogPost>( | |
graphql` | |
query GetBlogPost($postId: ID!) { | |
blogPostById(id: $postId) { | |
...BlogPostHead_blogPost | |
...BlogPostBody_blogPost | |
} | |
} | |
`, | |
{ | |
variables: { postId } | |
} | |
); | |
if (!blogPostById) { | |
return null; | |
} | |
return ( | |
<div> | |
<BlogPostHead blogPost={blogPostById} /> | |
<BlogPostBody blogPost={blogPostById} /> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment