From cbabb1948b246b51cd502c542351e9d582080038 Mon Sep 17 00:00:00 2001 From: Samuel Hurel Date: Tue, 10 Dec 2024 22:39:31 +0100 Subject: [PATCH] feat: add sortable search (#2623) --- packages/query/README.md | 6 +++--- packages/query/src/graphql/plugins/PgSearchPlugin.ts | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/query/README.md b/packages/query/README.md index 29b99da5d7..c330ca2af4 100644 --- a/packages/query/README.md +++ b/packages/query/README.md @@ -4,7 +4,7 @@ To quickly setup the project, add a `.env` file in the `subql/packages/query` folder with the following content: -``` +```env DB_HOST=localhost DB_PORT=5432 DB_USER=postgres @@ -14,6 +14,6 @@ DB_DATABASE=postgres then run the following command -``` -$ NODE_OPTIONS="-r dotenv/config" yarn start -- --name --playground +```sh +NODE_OPTIONS="-r dotenv/config" yarn start:dev -- --name --playground ``` diff --git a/packages/query/src/graphql/plugins/PgSearchPlugin.ts b/packages/query/src/graphql/plugins/PgSearchPlugin.ts index 770a61729f..4688f194aa 100644 --- a/packages/query/src/graphql/plugins/PgSearchPlugin.ts +++ b/packages/query/src/graphql/plugins/PgSearchPlugin.ts @@ -15,6 +15,7 @@ export const PgSearchPlugin: Plugin = (builder) => { // Sanitises the search argument for fulltext search using pg-tsquery builder.hook('GraphQLObjectType:fields:field', (field, build, {scope: {pgFieldIntrospection}}: Context) => { if (isProcedure(pgFieldIntrospection) && pgFieldIntrospection.argNames.includes('search')) { + pgFieldIntrospection.tags.sortable = true; return { ...field, resolve(source, args, ctx, info) {