mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
- it wasn't really making sense to have one query for all users/posts, future hashtags, because we change the first/offset when the user paginates, which would unneccesarily refetch all other resources. - the solution was to separate them into their own queries and only refetch when the user wants to paginate the resources.
62 lines
1.3 KiB
JavaScript
62 lines
1.3 KiB
JavaScript
import gql from 'graphql-tag'
|
|
import { userFragment, postFragment, tagsCategoriesAndPinnedFragment } from './Fragments'
|
|
|
|
export const searchQuery = gql`
|
|
${userFragment}
|
|
${postFragment}
|
|
${tagsCategoriesAndPinnedFragment}
|
|
|
|
query($query: String!, $firstPosts: Int, $firstUsers: Int, $offset: Int) {
|
|
searchResults(
|
|
query: $query
|
|
firstPosts: $firstPosts
|
|
firstUsers: $firstUsers
|
|
offset: $offset
|
|
) {
|
|
__typename
|
|
... on Post {
|
|
...post
|
|
...tagsCategoriesAndPinned
|
|
commentsCount
|
|
shoutedCount
|
|
author {
|
|
...user
|
|
}
|
|
}
|
|
... on User {
|
|
...user
|
|
}
|
|
}
|
|
}
|
|
`
|
|
|
|
export const searchPosts = gql`
|
|
${userFragment}
|
|
${postFragment}
|
|
${tagsCategoriesAndPinnedFragment}
|
|
|
|
query($query: String!, $firstPosts: Int, $postsOffset: Int) {
|
|
searchPosts(query: $query, firstPosts: $firstPosts, postsOffset: $postsOffset) {
|
|
__typename
|
|
...post
|
|
...tagsCategoriesAndPinned
|
|
commentsCount
|
|
shoutedCount
|
|
author {
|
|
...user
|
|
}
|
|
}
|
|
}
|
|
`
|
|
|
|
export const searchUsers = gql`
|
|
${userFragment}
|
|
|
|
query($query: String!, $firstUsers: Int, $usersOffset: Int) {
|
|
searchUsers(query: $query, firstUsers: $firstUsers, usersOffset: $usersOffset) {
|
|
__typename
|
|
...user
|
|
}
|
|
}
|
|
`
|