mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2026-04-06 01:25:31 +00:00
Clean up
- remove the code for subscriptions to Post as we won't implement this at this time... I've created a new branch with the code that can be built on later - remove unused subscription path - add possibility to use websockets uri for production env.
This commit is contained in:
parent
1c6a5503db
commit
6cf067937d
@ -49,7 +49,6 @@ export const serverConfigs = {
|
|||||||
CLIENT_URI,
|
CLIENT_URI,
|
||||||
GRAPHQL_URI,
|
GRAPHQL_URI,
|
||||||
PUBLIC_REGISTRATION: process.env.PUBLIC_REGISTRATION === 'true',
|
PUBLIC_REGISTRATION: process.env.PUBLIC_REGISTRATION === 'true',
|
||||||
SUBSCRIPTIONS_PATH: '/subscriptions',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const developmentConfigs = {
|
export const developmentConfigs = {
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
import uuid from 'uuid/v4'
|
import uuid from 'uuid/v4'
|
||||||
import { neo4jgraphql } from 'neo4j-graphql-js'
|
import { neo4jgraphql } from 'neo4j-graphql-js'
|
||||||
import { isEmpty } from 'lodash'
|
import { isEmpty } from 'lodash'
|
||||||
import { UserInputError, PubSub } from 'apollo-server'
|
import { UserInputError } from 'apollo-server'
|
||||||
import fileUpload from './fileUpload'
|
import fileUpload from './fileUpload'
|
||||||
import Resolver from './helpers/Resolver'
|
import Resolver from './helpers/Resolver'
|
||||||
import { filterForMutedUsers } from './helpers/filterForMutedUsers'
|
import { filterForMutedUsers } from './helpers/filterForMutedUsers'
|
||||||
|
|
||||||
const pubsub = new PubSub()
|
|
||||||
const POST_ADDED = 'POST_ADDED'
|
|
||||||
|
|
||||||
const maintainPinnedPosts = params => {
|
const maintainPinnedPosts = params => {
|
||||||
const pinnedPostFilter = { pinned: true }
|
const pinnedPostFilter = { pinned: true }
|
||||||
if (isEmpty(params.filter)) {
|
if (isEmpty(params.filter)) {
|
||||||
@ -20,12 +17,6 @@ const maintainPinnedPosts = params => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Subscription: {
|
|
||||||
postAdded: {
|
|
||||||
// Additional event labels can be passed to asyncIterator creation
|
|
||||||
subscribe: () => pubsub.asyncIterator([POST_ADDED]),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Query: {
|
Query: {
|
||||||
Post: async (object, params, context, resolveInfo) => {
|
Post: async (object, params, context, resolveInfo) => {
|
||||||
params = await filterForMutedUsers(params, context)
|
params = await filterForMutedUsers(params, context)
|
||||||
@ -111,7 +102,6 @@ export default {
|
|||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
const [post] = await writeTxResultPromise
|
const [post] = await writeTxResultPromise
|
||||||
pubsub.publish(POST_ADDED, { postAdded: post })
|
|
||||||
return post
|
return post
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.code === 'Neo.ClientError.Schema.ConstraintValidationFailed')
|
if (e.code === 'Neo.ClientError.Schema.ConstraintValidationFailed')
|
||||||
|
|||||||
@ -245,7 +245,3 @@ type Query {
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Subscription {
|
|
||||||
postAdded: Post
|
|
||||||
}
|
|
||||||
|
|||||||
@ -74,15 +74,6 @@ import { mapGetters, mapMutations } from 'vuex'
|
|||||||
import { filterPosts } from '~/graphql/PostQuery.js'
|
import { filterPosts } from '~/graphql/PostQuery.js'
|
||||||
import PostMutations from '~/graphql/PostMutations'
|
import PostMutations from '~/graphql/PostMutations'
|
||||||
import UpdateQuery from '~/components/utils/UpdateQuery'
|
import UpdateQuery from '~/components/utils/UpdateQuery'
|
||||||
import gql from 'graphql-tag'
|
|
||||||
import {
|
|
||||||
userFragment,
|
|
||||||
postFragment,
|
|
||||||
postCountsFragment,
|
|
||||||
userCountsFragment,
|
|
||||||
locationAndBadgesFragment,
|
|
||||||
tagsCategoriesAndPinnedFragment,
|
|
||||||
} from '~/graphql/Fragments'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -222,35 +213,6 @@ export default {
|
|||||||
this.posts = Post
|
this.posts = Post
|
||||||
},
|
},
|
||||||
fetchPolicy: 'cache-and-network',
|
fetchPolicy: 'cache-and-network',
|
||||||
subscribeToMore: {
|
|
||||||
document: gql`
|
|
||||||
${userFragment}
|
|
||||||
${userCountsFragment}
|
|
||||||
${locationAndBadgesFragment('EN')}
|
|
||||||
${postFragment}
|
|
||||||
${postCountsFragment}
|
|
||||||
${tagsCategoriesAndPinnedFragment}
|
|
||||||
|
|
||||||
subscription Post {
|
|
||||||
postAdded {
|
|
||||||
...post
|
|
||||||
...postCounts
|
|
||||||
...tagsCategoriesAndPinned
|
|
||||||
author {
|
|
||||||
...user
|
|
||||||
...userCounts
|
|
||||||
...locationAndBadges
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
updateQuery: (previousResult, { subscriptionData }) => {
|
|
||||||
const {
|
|
||||||
data: { postAdded: newPost },
|
|
||||||
} = subscriptionData
|
|
||||||
return { Post: [newPost, ...previousResult.Post] }
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ export default ({ app }) => {
|
|||||||
const backendUrl = process.env.GRAPHQL_URI || 'http://localhost:4000'
|
const backendUrl = process.env.GRAPHQL_URI || 'http://localhost:4000'
|
||||||
|
|
||||||
return {
|
return {
|
||||||
wsEndpoint: 'ws://localhost:4000/graphql', // optional
|
wsEndpoint: process.env.WEBSOCKETS_URI || 'ws://localhost:4000/graphql',
|
||||||
httpEndpoint: process.server ? backendUrl : '/api',
|
httpEndpoint: process.server ? backendUrl : '/api',
|
||||||
httpLinkOptions: {
|
httpLinkOptions: {
|
||||||
credentials: 'same-origin',
|
credentials: 'same-origin',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user