From 6fb926e735d14eb3438b616f0942f04e9db51514 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Tue, 13 Aug 2019 16:46:52 +0200 Subject: [PATCH] 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. --- backend/src/schema/types/schema.gql | 5 +++-- webapp/store/search.js | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/src/schema/types/schema.gql b/backend/src/schema/types/schema.gql index b8e5f5290..560669a7d 100644 --- a/backend/src/schema/types/schema.gql +++ b/backend/src/schema/types/schema.gql @@ -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 """ diff --git a/webapp/store/search.js b/webapp/store/search.js index 4aeb5030d..c5ed9523a 100644 --- a/webapp/store/search.js +++ b/webapp/store/search.js @@ -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 => {