mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Trying to get the backend working
This commit is contained in:
parent
81842592df
commit
4264bb2af7
@ -83,7 +83,9 @@ export default shield(
|
||||
{
|
||||
Query: {
|
||||
'*': deny,
|
||||
findPosts: allow,
|
||||
findPosts: allow,
|
||||
findUsers: allow,
|
||||
findAnything: allow,
|
||||
embed: allow,
|
||||
Category: allow,
|
||||
Tag: allow,
|
||||
|
||||
31
backend/src/schema/resolvers/#searches.js#
Normal file
31
backend/src/schema/resolvers/#searches.js#
Normal file
@ -0,0 +1,31 @@
|
||||
import { neo4jgraphql } from 'neo4j-graphql-js'
|
||||
import posts from './posts.js'
|
||||
import users from './users.js'
|
||||
|
||||
const postArgs = (args, query) => {
|
||||
args.query = query.replace(/\s/g, '~ ') + '~'
|
||||
args.filter = {}
|
||||
return args
|
||||
}
|
||||
|
||||
const userArgs = (args, query) => {
|
||||
args.query = new RegExp('(?i).*BOB.*')//(?i).*' + query + '.*
|
||||
args.filter = {}
|
||||
return args
|
||||
}
|
||||
|
||||
export default {
|
||||
Query: {
|
||||
findAnything: async (_parent, args, context, _resolveInfo) => {
|
||||
const query = args.query
|
||||
console.log('postArgs', postArgs(args, query))
|
||||
const postResults = await posts.Query.findPosts(_parent, postArgs(args, query), context, _resolveInfo)
|
||||
console.log('Posts', postResults)
|
||||
//console.log('userArgs', userArgs(args, query))
|
||||
//const userResults = await users.Query.findUsers(_parent, userArgs(args, query), context, _resolveInfo)
|
||||
//console.log('Users', userResults)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,8 +47,10 @@ export default {
|
||||
return neo4jgraphql(object, params, context, resolveInfo)
|
||||
},
|
||||
findPosts: async (object, params, context, resolveInfo) => {
|
||||
params = await filterForBlockedUsers(params, context)
|
||||
return neo4jgraphql(object, params, context, resolveInfo)
|
||||
params = await filterForBlockedUsers(params, context)
|
||||
const debug = await neo4jgraphql(object, params, context, resolveInfo, true)
|
||||
console.log('debug', debug)
|
||||
return debug
|
||||
},
|
||||
profilePagePosts: async (object, params, context, resolveInfo) => {
|
||||
params = await filterForBlockedUsers(params, context)
|
||||
|
||||
30
backend/src/schema/resolvers/searches.js
Normal file
30
backend/src/schema/resolvers/searches.js
Normal file
@ -0,0 +1,30 @@
|
||||
import posts from './posts.js'
|
||||
import users from './users.js'
|
||||
|
||||
const postArgs = (args, query) => {
|
||||
args.query = query.replace(/\s/g, '~ ') + '~'
|
||||
args.filter = {}
|
||||
return args
|
||||
}
|
||||
|
||||
const userArgs = (args, query) => {
|
||||
args.query = new RegExp('(?i).*BOB.*')//(?i).*' + query + '.*
|
||||
args.filter = {}
|
||||
return args
|
||||
}
|
||||
|
||||
export default {
|
||||
Query: {
|
||||
findAnything: async (_parent, args, context, _resolveInfo) => {
|
||||
const query = args.query
|
||||
console.log('postArgs', postArgs(args, query))
|
||||
const postResults = await posts.Query.findPosts(_parent, postArgs(args, query), context, _resolveInfo)
|
||||
console.log('Posts', postResults)
|
||||
//console.log('userArgs', userArgs(args, query))
|
||||
//const userResults = await users.Query.findUsers(_parent, userArgs(args, query), context, _resolveInfo)
|
||||
//console.log('Users', userResults)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,6 +45,13 @@ export default {
|
||||
} catch (e) {
|
||||
throw new UserInputError(e.message)
|
||||
}
|
||||
},
|
||||
findUsers: async (object, params, context, resolveInfo) => {
|
||||
console.log('params', params)
|
||||
//const blockedUsers = await getBlockedUsers(context)
|
||||
const debug = await neo4jgraphql(object, params, context, resolveInfo, true)
|
||||
console.log('debug', debug)
|
||||
return debug
|
||||
},
|
||||
User: async (object, args, context, resolveInfo) => {
|
||||
const { email } = args
|
||||
|
||||
@ -1,23 +1,3 @@
|
||||
type Query {
|
||||
isLoggedIn: Boolean!
|
||||
# Get the currently logged in User based on the given JWT Token
|
||||
currentUser: User
|
||||
findPosts(query: String!, limit: Int = 10, filter: _PostFilter): [Post]!
|
||||
@cypher(
|
||||
statement: """
|
||||
CALL db.index.fulltext.queryNodes('full_text_search', $query)
|
||||
YIELD node as post, score
|
||||
MATCH (post)<-[:WROTE]-(user:User)
|
||||
WHERE score >= 0.2
|
||||
AND NOT user.deleted = true AND NOT user.disabled = true
|
||||
AND NOT post.deleted = true AND NOT post.disabled = true
|
||||
AND NOT user.id in COALESCE($filter.author_not.id_in, [])
|
||||
RETURN post
|
||||
LIMIT $limit
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
# Get a JWT Token for the given Email and password
|
||||
login(email: String!, password: String!): String!
|
||||
|
||||
@ -226,4 +226,20 @@ type Query {
|
||||
PostsEmotionsCountByEmotion(postId: ID!, data: _EMOTEDInput!): Int!
|
||||
PostsEmotionsByCurrentUser(postId: ID!): [String]
|
||||
profilePagePosts(filter: _PostFilter, first: Int, offset: Int, orderBy: [_PostOrdering]): [Post]
|
||||
isLoggedIn: Boolean!
|
||||
currentUser: User
|
||||
findPosts(query: String!, limit: Int = 10, filter: _PostFilter): [Post]!
|
||||
@cypher(
|
||||
statement: """
|
||||
CALL db.index.fulltext.queryNodes('full_text_search', $query)
|
||||
YIELD node as post, score
|
||||
MATCH (post)<-[:WROTE]-(user:User)
|
||||
WHERE score >= 0.2
|
||||
AND NOT user.deleted = true AND NOT user.disabled = true
|
||||
AND NOT post.deleted = true AND NOT post.disabled = true
|
||||
AND NOT user.id in COALESCE($filter.author_not.id_in, [])
|
||||
RETURN post
|
||||
LIMIT $limit
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
5
backend/src/schema/types/type/Search.gql
Normal file
5
backend/src/schema/types/type/Search.gql
Normal file
@ -0,0 +1,5 @@
|
||||
union SearchResult = Post | User
|
||||
|
||||
type Query {
|
||||
findAnything(query: String!, limit: Int = 10): [Post]
|
||||
}
|
||||
@ -161,7 +161,17 @@ type Query {
|
||||
): [User]
|
||||
|
||||
blockedUsers: [User]
|
||||
currentUser: User
|
||||
currentUser: User
|
||||
findUsers(query: String!,limit: Int = 10, filter: _UserFilter): [User]!
|
||||
@cypher(
|
||||
statement: """
|
||||
MATCH (user:User)
|
||||
WHERE (user.name =~ $query OR user.slug =~ $query)
|
||||
AND NOT user.deleted = true AND NOT user.disabled = true
|
||||
RETURN user
|
||||
LIMIT $limit
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user