This repository was archived by the owner on Feb 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +27
-45
lines changed Expand file tree Collapse file tree 1 file changed +27
-45
lines changed Original file line number Diff line number Diff line change
1
+ import globalPostFields from '../_partials/globalPostFields'
2
+ import seoPostFields from '../_partials/seoPostFields'
3
+ import authorPostFields from '../_partials/authorPostFields'
4
+ import featuredImagePostFields from '../_partials/featuredImagePostFields'
5
+ import tagsPostFields from '../_partials/tagsPostFields'
6
+ import categoriesPostFields from '../_partials/categoriesPostFields'
7
+
1
8
const { gql} = require ( '@apollo/client' )
2
9
10
+ // Fragment: retrieve single page fields.
11
+ const singlePostFragment = gql `
12
+ fragment SinglePostFields on Post {
13
+ ${ globalPostFields }
14
+ blocksJSON
15
+ excerpt
16
+ ${ seoPostFields }
17
+ ${ authorPostFields }
18
+ ${ featuredImagePostFields }
19
+ ${ tagsPostFields }
20
+ ${ categoriesPostFields }
21
+ }
22
+ `
3
23
// Query: retrieve post by specified identifier.
4
24
const queryPostById = gql `
5
- query GET_POST_BY_SLUG($id: ID!, $idType: PostIdType = SLUG) {
25
+ query GET_POST_BY_SLUG(
26
+ $id: ID!
27
+ $idType: PostIdType = SLUG
28
+ $imageSize: MediaItemSizeEnum = LARGE
29
+ ) {
6
30
post(id: $id, idType: $idType) {
7
- blocksJSON
8
- databaseId
9
- date
10
- slug
11
- title
12
- excerpt
13
- seo {
14
- canonical
15
- title
16
- metaDesc
17
- metaRobotsNofollow
18
- metaRobotsNoindex
19
- opengraphImage {
20
- sourceUrl
21
- }
22
- }
23
- tags {
24
- edges {
25
- node {
26
- name
27
- slug
28
- }
29
- }
30
- }
31
- author {
32
- node {
33
- slug
34
- nickname
35
- }
36
- }
37
- categories {
38
- edges {
39
- node {
40
- slug
41
- name
42
- }
43
- }
44
- }
45
- featuredImage {
46
- node {
47
- altText
48
- sourceUrl(size: LARGE)
49
- }
50
- }
31
+ ...SinglePostFields
51
32
}
52
33
}
34
+ ${ singlePostFragment }
53
35
`
54
36
55
37
export default queryPostById
You can’t perform that action at this time.
0 commit comments