Proposal: case-insensitive APQ hash validation
- Ngôn ngữ chính
- Go
- Star
- 10.8k
- Fork
- 1.3k
- Merge trung bình
- 2 ngày 36 phút
- Pull request đã merge (30 ngày)
- 26
Mô tả
### What happened?
The server returns an error `provided APQ hash does not match query` even when the queries in question are equal.
This happens because of this line:
https://github.com/99designs/gqlgen/blob/cc177859d901ab166fc2c5d741ace906e91fb225/graphql/handler/extension/apq.go#L85
Here, the internal hash, calculated in `computeQueryHash` is compared with the received hash from the client in `extension.Sha256`.
Here's the problem:
`computeQueryHash` uses `hex.EncodeToString` which always returns **lowercase** hex characters.
**The hash from the client might not be lowercase though.**
In my case, I use the C# client (https://github.com/graphql-dotnet/graphql-client#automatic-persisted-queries-apq) which always returns **uppercase** hashes.
The above-mentioned line in `apq.go` performs a simple string comparison and since `123abc != 123ABC`, it returns an error even if these two hashes are idempotent.
### What did you expect?
Hashes to be compared case-insensitively, e.g. by using [`strings.EqualFold`](https://pkg.go.dev/strings#EqualFold).
I have a fork with this fix ready if feedback on this suggestion is positive (I created this issue first instead of directly raising a PR according to the [contribution guidelines](https://github.com/99designs/gqlgen/blob/master/CONTRIBUTING.md)).
### Minimal graphql.schema and models to reproduce
n/a
### versions
- `gqlgen@v0.17.53`
- `go 1.23.0`
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.