Matt Rider d511d6aa78 Refactor graphql queries
- Remove duplicate queries
- Use smart query in pages/post/_id/_slug/index.vue to avoid multiple db requests for a post and its comments.
We cannot update the apollo cache with asyncData and smart queries have a prefetch policy set to true by default, which
means that they will resolve in a similar timeframe. https://stackoverflow.com/questions/55885337/in-nuxt-should-i-use-asyncdata-or-default-apollo-queries
https://vue-apollo.netlify.com/api/smart-query.html#options
https://vue-apollo.netlify.com/guide/ssr.html#vue-cli-plugin
2019-08-16 11:25:53 +02:00

78 lines
1.4 KiB
JavaScript

import gql from 'graphql-tag'
export default i18n => {
const lang = i18n.locale().toUpperCase()
return gql`
query User($id: ID!) {
User(id: $id) {
id
slug
name
avatar
about
disabled
deleted
locationName
location {
name: name${lang}
}
createdAt
badges {
id
icon
}
badgesCount
shoutedCount
commentedCount
followingCount
following(first: 7) {
id
slug
name
avatar
disabled
deleted
followedByCount
followedByCurrentUser
contributionsCount
commentsCount
badges {
id
icon
}
location {
name: name${lang}
}
}
followedByCount
followedByCurrentUser
isBlocked
followedBy(first: 7) {
id
slug
name
disabled
deleted
avatar
followedByCount
followedByCurrentUser
contributionsCount
commentsCount
badges {
id
icon
}
location {
name: name${lang}
}
}
contributionsCount
socialMedia {
id
url
}
}
}
`
}