Fix Search.feature in a hacky way

Ok, we have no control what parameters are passed to the cypher query
generated by `neo4j-graphql-js`. So I'm re-using the `filter` param.
If the `$filter` param is `{}` then we can use COALESCE to turn that
into empty array. Ugh.
This commit is contained in:
roschaefer 2019-08-13 16:46:52 +02:00
parent 717147bd0c
commit 6fb926e735
2 changed files with 6 additions and 5 deletions

View File

@ -4,15 +4,16 @@ type Query {
currentUser: User
# Get the latest Network Statistics
statistics: Statistics!
findPosts(filter: String!, limit: Int = 10): [Post]!
findPosts(query: String!, limit: Int = 10): [Post]!
@cypher(
statement: """
CALL db.index.fulltext.queryNodes('full_text_search', $filter)
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
"""

View File

@ -46,8 +46,8 @@ export const actions = {
await this.app.apolloProvider.defaultClient
.query({
query: gql(`
query findPosts($filter: String!) {
findPosts(filter: $filter, limit: 10) {
query findPosts($query: String!) {
findPosts(query: $query, limit: 10) {
id
slug
label: title
@ -64,7 +64,7 @@ export const actions = {
}
`),
variables: {
filter: value.replace(/\s/g, '~ ') + '~',
query: value.replace(/\s/g, '~ ') + '~',
},
})
.then(res => {