hasura / hasura/graphql-engine
Allow String query variable to be used for citext fields too
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Version Information
Server Version: v2.12.0-ce
### Environment
OSS
### What is the current behaviour?
I have a query for search. the query search in multiple fields to match a maximum of record.
Some field are in varchar and some other are citext. I can use the same variable
### What is the expected behaviour?
Since citext is text, It should able to use the same variable to search in both text / citext fields
### How to reproduce the issue?
1. create tables
```sql
CREATE TABLE structure(
id uuid PRIMARY KEY,
name citext NOT NULL,
);
CREATE TABLE user(
user_id uuid PRIMARY KEY,
firstname varchar(25) NOT NULL,
lastname varchar(30) NOT NULL
structure_id uuid FOREIGN KEY ("structure_id") REFERENCES user("id") ON UPDATE restrict ON DELETE cascade,
);
```
2. open Api explorer
```gql
query search($search: String) {
user(
where: {
_or: [
{ firstname: { _ilike: $search } }
{ lastname: { _ilike: $search } }
{ structure: { name: { _ilike: $search } } } # structure.name use citext type
]
}
) {firstname, lastname}
}
```
4.
### Screenshots or Screencast

### Please provide any traces or logs that could help here.
the query produces the following error
```json
{
"errors": [
{
"extensions": {
"code": "validation-failed",
"path": "$.selectionSet.user.args.where.structure.name._eq"
},
"message": "variable 'search' is declared as 'String', but used where 'citext' is expected"
}
]
}
```
### Any possible solutions?
### Can you identify the location in the source code where the problem exists?
no, (I don't know haskell)
### If the bug is confirmed, would you be willing to submit a PR?
no (I don't know haskell)
### Keywords
citext
Contributor guide
Research direction
Start by reproducing the reported query in the API explorer against PostgreSQL fields using varchar and citext, then trace the variable-type validation that produces the shown error path. Done means one String variable can be used for both varchar and citext search fields without validation failure, with coverage for the provided query shape.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, haskell, postgresql
- Domain
- api, backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100