diff --git a/graphql/UserProfileQuery.js b/graphql/UserProfileQuery.js index a67d0d927..4e0245b52 100644 --- a/graphql/UserProfileQuery.js +++ b/graphql/UserProfileQuery.js @@ -1,80 +1,89 @@ import gql from 'graphql-tag' -export default gql(` - query User($slug: String!, $first: Int, $offset: Int) { - User(slug: $slug) { - id - name - avatar - about - locationName - location { - name - } - createdAt - badges { - id - key - icon - } - badgesCount - shoutedCount - commentsCount - followingCount - following(first: 7) { +export default app => { + const lang = app.$i18n.locale().toUpperCase() + return gql(` + query User($slug: String!, $first: Int, $offset: Int) { + User(slug: $slug) { id name - slug avatar - followedByCount - contributionsCount - commentsCount + about + locationName + location { + name: name${lang} + } + createdAt badges { id key icon } - } - followedByCount - followedBy(first: 7) { - id - name - slug - avatar - followedByCount - contributionsCount - commentsCount - badges { - id - key - icon - } - } - contributionsCount - contributions(first: $first, offset: $offset, orderBy: createdAt_desc) { - id - slug - title - contentExcerpt + badgesCount shoutedCount commentsCount - deleted - image - createdAt - categories { + followingCount + following(first: 7) { id name - icon - } - author { - id + slug avatar - name + followedByCount + contributionsCount + commentsCount + badges { + id + key + icon + } location { + name: name${lang} + } + } + followedByCount + followedBy(first: 7) { + id + name + slug + avatar + followedByCount + contributionsCount + commentsCount + badges { + id + key + icon + } + location { + name: name${lang} + } + } + contributionsCount + contributions(first: $first, offset: $offset, orderBy: createdAt_desc) { + id + slug + title + contentExcerpt + shoutedCount + commentsCount + deleted + image + createdAt + categories { + id name + icon + } + author { + id + avatar + name + location { + name: name${lang} + } } } } } - } -`) + `) +} diff --git a/nuxt.config.js b/nuxt.config.js index 46eed5420..f71331b4e 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -62,6 +62,7 @@ module.exports = { */ plugins: [ { src: '~/plugins/i18n.js', ssr: true }, + { src: '~/plugins/axios.js', ssr: false }, { src: '~/plugins/keep-alive.js', ssr: false }, { src: '~/plugins/design-system.js', ssr: true }, { src: '~/plugins/vue-directives.js', ssr: false }, diff --git a/pages/index.vue b/pages/index.vue index 58fdb284d..ec0f3f31e 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -79,43 +79,45 @@ export default { }, apollo: { Post: { - query: gql(` - query Post($first: Int, $offset: Int) { - Post(first: $first, offset: $offset) { - id - title - contentExcerpt - createdAt - slug - image - author { + query() { + return gql(` + query Post($first: Int, $offset: Int) { + Post(first: $first, offset: $offset) { id - avatar + title + contentExcerpt + createdAt slug - name - contributionsCount - shoutedCount - commentsCount - followedByCount - location { - name - } - badges { + image + author { id - key + avatar + slug + name + contributionsCount + shoutedCount + commentsCount + followedByCount + location { + name: name${this.$i18n.locale().toUpperCase()} + } + badges { + id + key + icon + } + } + commentsCount + categories { + id + name icon } + shoutedCount } - commentsCount - categories { - id - name - icon - } - shoutedCount } - } - `), + `) + }, variables() { return { first: this.pageSize, diff --git a/pages/post/_slug/index.vue b/pages/post/_slug/index.vue index 2b6b91f05..187319889 100644 --- a/pages/post/_slug/index.vue +++ b/pages/post/_slug/index.vue @@ -143,42 +143,16 @@ export default { }, apollo: { Post: { - query: gql(` - query Post($slug: String!) { - Post(slug: $slug) { - id - title - content - createdAt - slug - image - author { + query() { + return gql(` + query Post($slug: String!) { + Post(slug: $slug) { id - slug - name - avatar - shoutedCount - contributionsCount - commentsCount - followedByCount - location { - name - } - badges { - id - key - icon - } - } - tags { - name - } - commentsCount - comments(orderBy: createdAt_desc) { - id - contentExcerpt + title + content createdAt - deleted + slug + image author { id slug @@ -189,24 +163,52 @@ export default { commentsCount followedByCount location { - name - } + name: name${this.$i18n.locale().toUpperCase()} + } badges { id key icon } } + tags { + name + } + commentsCount + comments(orderBy: createdAt_desc) { + id + contentExcerpt + createdAt + deleted + author { + id + slug + name + avatar + shoutedCount + contributionsCount + commentsCount + followedByCount + location { + name: name${this.$i18n.locale().toUpperCase()} + } + badges { + id + key + icon + } + } + } + categories { + id + name + icon + } + shoutedCount } - categories { - id - name - icon - } - shoutedCount } - } - `), + `) + }, variables() { return { slug: this.$route.params.slug diff --git a/pages/post/_slug/more-info.vue b/pages/post/_slug/more-info.vue index 1530c03b2..456c7c357 100644 --- a/pages/post/_slug/more-info.vue +++ b/pages/post/_slug/more-info.vue @@ -73,54 +73,56 @@ export default { }, apollo: { Post: { - query: gql(` - query Post($slug: String!) { - Post(slug: $slug) { - id - title - tags { - id - name - } - categories { - id - name - icon - } - relatedContributions(first: 2) { + query() { + return gql(` + query Post($slug: String!) { + Post(slug: $slug) { id title - slug - contentExcerpt - shoutedCount - commentsCount + tags { + id + name + } categories { id name icon } - author { + relatedContributions(first: 2) { id - name + title slug - avatar - contributionsCount - followedByCount + contentExcerpt + shoutedCount commentsCount - location { - name - } - badges { + categories { id - key + name icon } + author { + id + name + slug + avatar + contributionsCount + followedByCount + commentsCount + location { + name: name${this.$i18n.locale().toUpperCase()} + } + badges { + id + key + icon + } + } } + shoutedCount } - shoutedCount } - } - `), + `) + }, variables() { return { slug: this.$route.params.slug diff --git a/pages/profile/_slug.vue b/pages/profile/_slug.vue index 670a4e81b..743b9ca81 100644 --- a/pages/profile/_slug.vue +++ b/pages/profile/_slug.vue @@ -360,7 +360,9 @@ export default { }, apollo: { User: { - query: require('~/graphql/UserProfileQuery.js').default, + query() { + return require('~/graphql/UserProfileQuery.js').default(this) + }, variables() { return { slug: this.$route.params.slug,