summaryrefslogtreecommitdiffstats
path: root/src/services
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2021-12-20 22:59:32 +0100
committerArmand Philippot <git@armandphilippot.com>2021-12-20 22:59:32 +0100
commit168ed3215f659d44215fd02ac05cc1fe58be4e06 (patch)
tree48d15a4743749f483f50f919ffa94e38185588a1 /src/services
parentb181f93f0f26570696d3a90b58a966c56ac61047 (diff)
chore: create search view
Diffstat (limited to 'src/services')
-rw-r--r--src/services/graphql/queries.ts15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/services/graphql/queries.ts b/src/services/graphql/queries.ts
index b449612..652caa1 100644
--- a/src/services/graphql/queries.ts
+++ b/src/services/graphql/queries.ts
@@ -28,13 +28,22 @@ import { fetchApi } from './api';
export const getPublishedPosts = async ({
first = 10,
after = '',
+ searchQuery = '',
+}: {
+ first: number;
+ after?: string;
+ searchQuery?: string;
}): Promise<PostsList> => {
const query = gql`
- query AllPublishedPosts($first: Int, $after: String) {
+ query AllPublishedPosts($first: Int, $after: String, $searchQuery: String) {
posts(
after: $after
first: $first
- where: { status: PUBLISH, orderby: { field: DATE, order: DESC } }
+ where: {
+ status: PUBLISH
+ orderby: { field: DATE, order: DESC }
+ search: $searchQuery
+ }
) {
edges {
cursor
@@ -91,7 +100,7 @@ export const getPublishedPosts = async ({
}
`;
- const variables = { first, after };
+ const variables = { first, after, searchQuery };
const response = await fetchApi<RawPostsList>(query, variables);
const formattedPosts = response.posts.edges.map((post) => {
const formattedPost = getFormattedPostPreview(post.node);