From 290f74f815f1258694d943cd6eae3b91549c5817 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Fri, 3 Aug 2018 12:15:16 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8Added=20advanced=20filtering=20to=20Dy?= =?UTF-8?q?namic=20Routing=20(#9757)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs #9601, refs #9742 - Upgraded NQL to 0.1.0 - The new version of NQL supports aliases e.g. `tag: tags.slug`, which makes it possible to define `filter=tag:support` - Furthermore, this allows us to support advanced filtering like tag:[a,b] - In dynamic routing, we use mingo via NQL which has a slightly different feature set to GQL in the API: - AND NOT, OR and other advanced logic combos DO work on joined tables - Counts are not yet supported - The Dynamic Routing beta docs should describe that API filtering and Dynamic Routing filtering is different --- core/server/services/url/UrlGenerator.js | 6 ++++-- package.json | 2 +- yarn.lock | 22 +++++++++++----------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/core/server/services/url/UrlGenerator.js b/core/server/services/url/UrlGenerator.js index 0ad13b0305..fcb05e905b 100644 --- a/core/server/services/url/UrlGenerator.js +++ b/core/server/services/url/UrlGenerator.js @@ -1,7 +1,9 @@ const _ = require('lodash'), nql = require('@nexes/nql'), debug = require('ghost-ignition').debug('services:url:generator'), - localUtils = require('./utils'); + localUtils = require('./utils'), + + aliases = {author: 'authors.slug', tags: 'tags.slug', tag: 'tags.slug', authors: 'authors.slug'}; class UrlGenerator { constructor(router, queue, resources, urls, position) { @@ -16,7 +18,7 @@ class UrlGenerator { // CASE: routers can define custom filters, but not required. if (this.router.getFilter()) { this.filter = this.router.getFilter(); - this.nql = nql(this.filter); + this.nql = nql(this.filter, {aliases}); debug('filter', this.filter); } diff --git a/package.json b/package.json index c99675ad01..23dbc38d7f 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "cli": "^1.9.0" }, "dependencies": { - "@nexes/nql": "0.0.1", + "@nexes/nql": "0.1.0", "amperize": "0.3.7", "analytics-node": "2.4.1", "archiver": "1.3.0", diff --git a/yarn.lock b/yarn.lock index ce726aef53..2c20226bf7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,22 +2,22 @@ # yarn lockfile v1 -"@nexes/mongo-knex@0.0.0": - version "0.0.0" - resolved "https://registry.yarnpkg.com/@nexes/mongo-knex/-/mongo-knex-0.0.0.tgz#7a44a7263d8830c8416b90ba3c963c2c722e7b72" +"@nexes/mongo-knex@0.0.1": + version "0.0.1" + resolved "https://registry.yarnpkg.com/@nexes/mongo-knex/-/mongo-knex-0.0.1.tgz#141c8ca380e95c1460fe2abcd777d7fd2bb14e8f" dependencies: lodash "^4.17.10" -"@nexes/nql-lang@0.0.0": - version "0.0.0" - resolved "https://registry.yarnpkg.com/@nexes/nql-lang/-/nql-lang-0.0.0.tgz#eb0fb807aea8aa64d3d0b454f3d1167af394f39a" - -"@nexes/nql@0.0.1": +"@nexes/nql-lang@0.0.1": version "0.0.1" - resolved "https://registry.yarnpkg.com/@nexes/nql/-/nql-0.0.1.tgz#e8f5e5352badeffd67e371f22bccd41fa0c20c24" + resolved "https://registry.yarnpkg.com/@nexes/nql-lang/-/nql-lang-0.0.1.tgz#a13c023873f9bc11b9e4e284449c6cfbeccc8011" + +"@nexes/nql@0.1.0": + version "0.1.0" + resolved "https://registry.yarnpkg.com/@nexes/nql/-/nql-0.1.0.tgz#b63614d5874bebb387b58d3f1b9fb9602115cf62" dependencies: - "@nexes/mongo-knex" "0.0.0" - "@nexes/nql-lang" "0.0.0" + "@nexes/mongo-knex" "0.0.1" + "@nexes/nql-lang" "0.0.1" mingo "2.2.2" "@segment/loosely-validate-event@^1.1.2":