diff --git a/__tests__/__snapshots__/fulltext.test.js.snap b/__tests__/__snapshots__/fulltext.test.js.snap index 2ae7802..e781279 100644 --- a/__tests__/__snapshots__/fulltext.test.js.snap +++ b/__tests__/__snapshots__/fulltext.test.js.snap @@ -61,6 +61,7 @@ GraphQLSchema { }, "astNode": undefined, "extensionASTNodes": undefined, + "extensions": undefined, } `; @@ -125,6 +126,7 @@ GraphQLSchema { }, "astNode": undefined, "extensionASTNodes": undefined, + "extensions": undefined, } `; @@ -189,6 +191,7 @@ GraphQLSchema { }, "astNode": undefined, "extensionASTNodes": undefined, + "extensions": undefined, } `; @@ -253,6 +256,7 @@ GraphQLSchema { }, "astNode": undefined, "extensionASTNodes": undefined, + "extensions": undefined, } `; @@ -317,6 +321,7 @@ GraphQLSchema { }, "astNode": undefined, "extensionASTNodes": undefined, + "extensions": undefined, } `; @@ -399,6 +404,7 @@ GraphQLSchema { }, "astNode": undefined, "extensionASTNodes": undefined, + "extensions": undefined, } `; @@ -481,5 +487,6 @@ GraphQLSchema { }, "astNode": undefined, "extensionASTNodes": undefined, + "extensions": undefined, } `; diff --git a/package.json b/package.json index 242652a..eed509d 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ }, "dependencies": { "graphile-build-pg": "^4.2.0", - "pg-tsquery": "^6.4.2", + "pg-tsquery": "^8.1.0", "postgraphile-plugin-connection-filter": "^1.0.0-beta.28" }, "peerDependencies": { diff --git a/src/PostgraphileFullTextFilterPlugin.js b/src/PostgraphileFullTextFilterPlugin.js index e2efb53..589cc80 100644 --- a/src/PostgraphileFullTextFilterPlugin.js +++ b/src/PostgraphileFullTextFilterPlugin.js @@ -1,6 +1,8 @@ -const tsquery = require('pg-tsquery'); +const { Tsquery } = require('pg-tsquery'); const { omit } = require('graphile-build-pg'); +const tsquery = new Tsquery(); + module.exports = function PostGraphileFulltextFilterPlugin(builder) { builder.hook('inflection', (inflection, build) => build.extend(inflection, { fullTextScalarTypeName() { @@ -84,7 +86,7 @@ module.exports = function PostGraphileFulltextFilterPlugin(builder) { 'Performs a full text search on the field.', () => GraphQLString, (identifier, val, input, fieldName, queryBuilder) => { - const tsQueryString = tsquery(input); + const tsQueryString = `${tsquery.parse(input) || ''}`; queryBuilder.__fts_ranks = queryBuilder.__fts_ranks || {}; queryBuilder.__fts_ranks[fieldName] = [identifier, tsQueryString]; return sql.query`${identifier} @@ to_tsquery(${sql.value(tsQueryString)})`;