mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
183 lines
3.4 KiB
JavaScript
183 lines
3.4 KiB
JavaScript
import gql from 'graphql-tag'
|
|
import { linkableUserFragment, userFragment, postFragment, commentFragment } from './Fragments'
|
|
|
|
export default i18n => {
|
|
const lang = i18n.locale().toUpperCase()
|
|
return gql`
|
|
${userFragment(lang)}
|
|
|
|
query User($id: ID!) {
|
|
User(id: $id) {
|
|
...user
|
|
about
|
|
locationName
|
|
createdAt
|
|
badgesCount
|
|
followingCount
|
|
following(first: 7) {
|
|
...user
|
|
}
|
|
followedByCount
|
|
followedByCurrentUser
|
|
isBlocked
|
|
followedBy(first: 7) {
|
|
...user
|
|
}
|
|
socialMedia {
|
|
id
|
|
url
|
|
}
|
|
showShoutsPublicly
|
|
}
|
|
}
|
|
`
|
|
}
|
|
|
|
export const minimisedUserQuery = () => {
|
|
return gql`
|
|
query {
|
|
User(orderBy: slug_asc) {
|
|
id
|
|
slug
|
|
name
|
|
avatar
|
|
}
|
|
}
|
|
`
|
|
}
|
|
|
|
export const notificationQuery = i18n => {
|
|
const lang = i18n.locale().toUpperCase()
|
|
return gql`
|
|
${linkableUserFragment()}
|
|
${commentFragment(lang)}
|
|
${postFragment(lang)}
|
|
|
|
query($read: Boolean, $orderBy: NotificationOrdering, $first: Int, $offset: Int) {
|
|
notifications(read: $read, orderBy: $orderBy, first: $first, offset: $offset) {
|
|
id
|
|
read
|
|
reason
|
|
createdAt
|
|
from {
|
|
__typename
|
|
... on Post {
|
|
...post
|
|
}
|
|
... on Comment {
|
|
...comment
|
|
post {
|
|
...post
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`
|
|
}
|
|
|
|
export const markAsReadMutation = i18n => {
|
|
const lang = i18n.locale().toUpperCase()
|
|
return gql`
|
|
${linkableUserFragment()}
|
|
${commentFragment(lang)}
|
|
${postFragment(lang)}
|
|
|
|
mutation($id: ID!) {
|
|
markAsRead(id: $id) {
|
|
id
|
|
read
|
|
reason
|
|
createdAt
|
|
from {
|
|
__typename
|
|
... on Post {
|
|
...post
|
|
}
|
|
... on Comment {
|
|
...comment
|
|
post {
|
|
...post
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`
|
|
}
|
|
|
|
export const followUserMutation = i18n => {
|
|
const lang = i18n.locale().toUpperCase()
|
|
return gql`
|
|
${userFragment(lang)}
|
|
mutation($id: ID!) {
|
|
followUser(id: $id) {
|
|
name
|
|
followedByCount
|
|
followedByCurrentUser
|
|
followedBy(first: 7) {
|
|
...user
|
|
}
|
|
}
|
|
}
|
|
`
|
|
}
|
|
|
|
export const unfollowUserMutation = i18n => {
|
|
const lang = i18n.locale().toUpperCase()
|
|
return gql`
|
|
${userFragment(lang)}
|
|
mutation($id: ID!) {
|
|
unfollowUser(id: $id) {
|
|
name
|
|
followedByCount
|
|
followedByCurrentUser
|
|
followedBy(first: 7) {
|
|
...user
|
|
}
|
|
}
|
|
}
|
|
`
|
|
}
|
|
|
|
export const allowEmbedIframesMutation = () => {
|
|
return gql`
|
|
mutation($id: ID!, $allowEmbedIframes: Boolean) {
|
|
UpdateUser(id: $id, allowEmbedIframes: $allowEmbedIframes) {
|
|
id
|
|
allowEmbedIframes
|
|
}
|
|
}
|
|
`
|
|
}
|
|
|
|
export const showShoutsPubliclyMutation = () => {
|
|
return gql`
|
|
mutation($id: ID!, $showShoutsPublicly: Boolean) {
|
|
UpdateUser(id: $id, showShoutsPublicly: $showShoutsPublicly) {
|
|
id
|
|
showShoutsPublicly
|
|
}
|
|
}
|
|
`
|
|
}
|
|
|
|
export const checkSlugAvailableQuery = gql`
|
|
query($slug: String!) {
|
|
User(slug: $slug) {
|
|
slug
|
|
}
|
|
}
|
|
`
|
|
|
|
export const localeMutation = () => {
|
|
return gql`
|
|
mutation($id: ID!, $locale: String) {
|
|
UpdateUser(id: $id, locale: $locale) {
|
|
id
|
|
locale
|
|
}
|
|
}
|
|
`
|
|
}
|