Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Search case sensitivity #1967

Open
evanshortiss opened this issue Aug 31, 2020 · 10 comments
Open

Search case sensitivity #1967

evanshortiss opened this issue Aug 31, 2020 · 10 comments
Labels
enhancement New feature or request graphqlcrud

Comments

@evanshortiss
Copy link
Member

Is your feature request related to a problem? Please describe.

Yes. I'm trying to query a string field, but my query fails since it's case sensitive. For example the DB contains "GITHUB", but my search contains "github".

Describe the solution you'd like

The ability to toggle case sensitivity for a query using a Boolean.

Describe alternatives you've considered

Could regular expressions be an option? So instead of findJunctions (filter: { name: { contains: "BREA" } }) a developer could pass findJunctions (filter: { name: { regex "/brea/ig" } }).

@evanshortiss evanshortiss added the enhancement New feature or request label Aug 31, 2020
@machi1990
Copy link
Contributor

Automatically generated comment to notify maintainers
/cc @craicoverflow, @machi1990, @wtrocki

@craicoverflow
Copy link

The ability to toggle case sensitivity for a query using a Boolean.

I've thought about this and though it would be easy enough to add, the filter input fields are purely to map to an underlying database table/collection - adding case sensitivity to the filter would also mix configuration into it this. We don't want to make the inputs too complex.

In your particular use case, do you see the need to combine {name: { contains: "BREA" }} with other conditions, or is this solely as a search query?
If the latter, this would be a great additional plugin:

@wtrocki
Copy link
Contributor

wtrocki commented Sep 2, 2020

Yes. Text search is one of the proposed goals on roadmap post 1.0.
Doing any search, filtering on general entities now requires building complex filtering.

I'm thinking if there is workaround we can provide here.
Having custom resolver for this case with direct operation on knex/mongo is the obvious one.

@wtrocki
Copy link
Contributor

wtrocki commented Sep 2, 2020

Actually we can see if we can do something like Hasura done:
https://hasura.io/docs/1.0/graphql/core/queries/query-filters.html#text-search-or-pattern-matching-operators-like-similar-etc

@evanshortiss
Copy link
Member Author

@craicoverflow exactly, this is a search query on a string field and supporting the DB-level text search would be ideal since it removes most ambiguity.

great additional plugin

I'm not incredibly famiilar with how Graphback internals operate; are the various filters implemented as plugins? Once a plugin is authored it can be exposed as a filter in the schema, similar to what @wtrocki linked?

@craicoverflow
Copy link

Yes, the various filters that you see are applied to the schema through the SchemaCRUDPlugin, this is a default plugin that is automatically executed on startup.

What this plugin does:

  1. Creates the GraphQL schema with filters, queries, mutations, subscriptions using the data model you defined in the transformSchema plugin hook.
  2. Generates the appropriate resolvers for each query, mutation, subscription and relationship field through the createResolvers plugin hook. These resolvers interface with the GraphbackCRUDService CRUD interface to interface with the database.

This plugin-first approach makes it possible for anyone to add their own plugins, or for us to extend it in the future with relative ease. Our docs have an example plugin setup guide.

Data synhronisation is not embedded into the core of Graphback, instead it is a plugin: https://github.com/aerogear/graphback/blob/master/packages/graphback-datasync/src/DataSyncPlugin.ts#L20

@evanshortiss
Copy link
Member Author

That's very slick! I'll need to dig into it.

Do you think it's best to implement filters like this at the app level, and not Graphback level?

@wtrocki
Copy link
Contributor

wtrocki commented Sep 2, 2020

I think this specific issue - especially similar or ilike makes sense to be part of the core

@machi1990
Copy link
Contributor

I think this specific issue - especially similar or ilike makes sense to be part of the core

+100

@CoreyKovalik
Copy link
Collaborator

CoreyKovalik commented Jun 21, 2021

+1000, we are actually creating a normalized field on models i.e. lowercase_name for this use case

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request graphqlcrud
Projects
None yet
Development

No branches or pull requests

5 participants