Skip to content

Instantly share code, notes, and snippets.

@matlc
Created July 30, 2019 01:26
Show Gist options
  • Save matlc/5b32c9fa9df1cf5fdb13846e55ac36c6 to your computer and use it in GitHub Desktop.
Save matlc/5b32c9fa9df1cf5fdb13846e55ac36c6 to your computer and use it in GitHub Desktop.
// `blog-author.js`
export const query = graphql`
fragment postFields on PostsJson {
slug
title
content
publishDate(formatString: "MMMM DD, YYYY")
tags
}
fragment authorFields on AuthorsJson {
slug
name
biography
}
query ($id: String!) {
author: authorsJson(id: {eq: $id}) {
...authorFields
posts {
...postFields
}
}
}
`
// `blog-post.js`
export const query = graphql`
fragment postFields on PostsJson {
slug
title
content
publishDate(formatString: "MMMM DD, YYYY")
tags
}
fragment authorFields on AuthorsJson {
slug
name
biography
}
query ($id: String!) {
post: postsJson(id: {eq: $id}) {
...postFields
author {
...authorFields
}
}
}
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment