hasura / hasura/graphql-engine
server: native query relationship in filter expression not working (v2)
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Version Information
Server Version: 2.44
### Environment
Cloud
### What is the current behaviour?
Assume there exists a relationship between table and a native query. Please refer [this](https://hasura.io/docs/2.0/schema/postgres/table-relationships/create/#tracking-relationships-between-tables-and-native-queries) doc for example.
Now If user uses native query (nested object) in `where` clause as part of filter expression, it will throw error. Without including it in `where` clause it works fine.
Query
```gql
query MyQuery {
episodes(where: {podcasts: {title: {_ilike: "Episode 2"}}}) {
podcasts {
title
podcast_id
}
title
}
}
```
Response
```json
{
"errors": [
{
"message": "Internal Server Error",
"extensions": {
"path": "$",
"code": "unexpected",
"internal": {
"error": "translateBoolExp RelTargetNativeQuery"
}
}
}
]
}
```
### What is the expected behaviour?
There is a limitation in hasura where we don't support boolean expressions across relationships to Native Queries, however we include them in the schema as shown here in the screenshot. This means we should either
- work on feature support for having boolean expressions across relationships to Native queries
- OR don't show Native query relationship field in `where` clause hence as part of GQL schema (based on introspection)
### How to reproduce the issue?
1. Add database and track some tables which you want to expose as part of GraphQL API
2. Create a Native Query
3. Add a relationship between table and Native Query as per this [doc](https://hasura.io/docs/2.0/schema/postgres/table-relationships/create/#tracking-relationships-between-tables-and-native-queries)
4. Perform a GQL query with root field of tracked table and include NQ (nested object) in `where` clause
### Screenshots or Screencast
### Any possible solutions/workarounds you're aware of?
Only workaround is to not use `where` clause if you are selecting Native query relationship(nested object) as part of filter operation. But this can also be part of feature request since this is a known limitation.
### Keywords
Native Queries Filter Relationship
Contributor guide
Research direction
Reproduce the GraphQL query after creating the documented table–native-query relationship, then trace the `translateBoolExp RelTargetNativeQuery` failure named in the response. Decide whether the issue should support relationship boolean expressions or omit the native-query relationship from the `where` schema; done means the query no longer produces this unsupported schema/runtime mismatch and the chosen behavior is covered by a regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, postgres
- Domain
- api, databases
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100