hasura / hasura/graphql-engine

Support `HASURA_GRAPHQL_REDIRECT_GET_REQUESTS` environment variable

Open
#7,732 2 comments 0 reactions 0 assignees View on GitHub
k/enhancement
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Is your proposal related to a problem?

I'm serving a public API with Hasura which I would like to make easy for developers to start using. Right now, developers who are new to the API sometimes attempt to navigate to `https://api.example.com/`, where they see only:

```
{"path":"$","error":"resource does not exist","code":"not-found"}
```

Developers also occasionally send GET requests to `/v1/graphql`, where they see the same error. (Which can be particularly confusing – its plausible that they made a valid request but the server didn't find any results.)

### Describe the solution you'd like

I'd like Hasura to send back a 302 redirect to a helpful URL from the `HASURA_GRAPHQL_REDIRECT_GET_REQUESTS` environment variable, e.g. `https://docs.example.com` or `https://try.example.com` (where I've set up [graphql-playground](https://github.com/graphql/graphql-playground) preset to my API).

If Hasura is considering rendering some sort of standard, more descriptive error message on GET requests to `/v1/graphql`, it might instead be a good idea to have two environment variables, e.g. `HASURA_GRAPHQL_REDIRECT_GET_ROOT` (for redirecting traffic from `/`) and `HASURA_GRAPHQL_REDIRECT_GET_ENDPOINT` for redirecting GET traffic from `/v1/graphql` and other endpoints (`/v1beta1/relay`, etc.). A descriptive error message would be sufficient for GET requests to `/v1/graphql`, but I would still like to redirect users from the root `https://api.example.com/` to my `https://try.example.com/`.

### Describe alternatives you've considered

If I was running my own infrastructure, I could do this myself, but since I'm using Hasura Cloud, I can't even e.g. configure Kubernetes ingress rules or CDN rules. I'm stuck with the error messages unless I migrate off of Hasura Cloud.

### If the feature is approved, would you be willing to submit a PR?

Certainly! (Though I'm very new to Haskell, so I'd appreciate hints about how best to implement it.)

Contributor guide

Open the contributing guide

Research direction

Start by tracing request handling for GET / and /v1/graphql, the entry points named in the issue; no implementation files or tests are identified in the payload. Done means that the requested environment variable can configure a 302 redirect to its URL for the intended GET requests, with the behavior verified for the relevant endpoints.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
api, backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.