roschaefer 107409ecee Fix duplicate fragment user issue
This is refactoring all our fragments and fixing the warning about an
existing name `user`. Apparently, fragments should have a unique name
globally.

I decided to call `userFragment`, `postFragment` the fragments for one
object and use different names to query for related objects.

I would be glad to learn a better way to handle this.
2019-12-14 00:37:42 +01:00

92 lines
1.3 KiB
JavaScript

import gql from 'graphql-tag'
export const userFragment = gql`
fragment user on User {
id
slug
name
avatar
disabled
deleted
}
`
export const locationAndBadgesFragment = lang => gql`
fragment locationAndBadges on User {
location {
name: name${lang}
}
badges {
id
icon
}
}
`
export const userCountsFragment = gql`
fragment userCounts on User {
shoutedCount
contributionsCount
commentedCount
followedByCount
followedByCurrentUser
}
`
export const postFragment = gql`
fragment post on Post {
id
title
content
contentExcerpt
createdAt
updatedAt
disabled
deleted
slug
image
language
pinnedAt
imageAspectRatio
}
`
export const postCountsFragment = gql`
fragment postCounts on Post {
commentsCount
shoutedCount
shoutedByCurrentUser
emotionsCount
}
`
export const tagsCategoriesAndPinnedFragment = gql`
fragment tagsCategoriesAndPinned on Post {
tags {
id
}
categories {
id
slug
name
icon
}
pinnedBy {
id
name
role
}
}
`
export const commentFragment = gql`
fragment comment on Comment {
id
createdAt
updatedAt
disabled
deleted
content
contentExcerpt
}
`