Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit c3f3164

Browse files
committed
Abstract posts query partial
1 parent efeccf9 commit c3f3164

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

api/wordpress/posts/queryPostsArchive.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ export const archivePostFragment = gql`
1414
}
1515
`
1616

17+
// Query partial: retrieve archive fields.
18+
export const archivePosts = `
19+
posts(
20+
first: $first
21+
last: $last
22+
after: $after
23+
before: $before
24+
where: {orderby: {field: $orderBy, order: $order}}
25+
) {
26+
${archivePageInfo}
27+
edges {
28+
node {
29+
...ArchivePostFields
30+
}
31+
}
32+
}
33+
`
34+
1735
// Query: retrieve posts archive.
1836
const queryPostsArchive = gql`
1937
query GET_POSTS_ARCHIVE(
@@ -31,20 +49,7 @@ const queryPostsArchive = gql`
3149
${seoPostFields}
3250
}
3351
}
34-
posts(
35-
first: $first
36-
last: $last
37-
after: $after
38-
before: $before
39-
where: {orderby: {field: $orderBy, order: $order}}
40-
) {
41-
${archivePageInfo}
42-
edges {
43-
node {
44-
...ArchivePostFields
45-
}
46-
}
47-
}
52+
${archivePosts}
4853
}
4954
${archivePostFragment}
5055
`

0 commit comments

Comments
 (0)