hasura / hasura/graphql-engine

Problem with geometry/geography fields

Open
#9,154 0 comments 0 reactions 0 assignees View on GitHub
k/bug t/product-platform
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Discussed in https://github.com/hasura/graphql-engine/discussions/9095

Originally posted by **sdekna** October 10, 2022
I am trying to query a `Sellers` table `where` the location of the seller is within `x` m from location provided.
This is how my query looks like:
```
query sellersInRange ($location: geography! ) {
Sellers(where: {location: {_cast: {geography: {_st_d_within: {distance: 20000, from: $location}}}}}) {
id
status
description
is_new
location
image
name
Products{
Product{
id
name
price
description
Sauces{
Sauce{
id
name
image
}
}
}
}
}
}
```
The `location` variable is: `{"location": {"type": "Point" ,"coordinates": [13.191394465831182,32.88723208673258]}}`.
Using hasura's graphiql, when I write this variable hasura gives me a type error saying "Expecting value of type geography", when it is already so. If I make the query hasura, it gives me the desired results.

My problems lie here:
1- The field is of type `geometry` not `geography` (as hasura demands), and if I change the field type to `geography`, then hasura demands `geography`.
2- The query runs ok in graphiql but if I call it using any graphql client, it fails and gives me a "query error"... other queries work ok but when I attempt for the location querying it fails outside of graphiql.

Any ideas?

Contributor guide

Open the contributing guide

Research direction

Start by reading the linked discussion 9095 and reproducing the Sellers query with the geography variable in GraphiQL and through a GraphQL client. Compare the geometry/geography field behavior and client error, then define done as consistent, documented behavior for the location query outside GraphiQL.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, postgres
Domain
api, database
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.