graphql-engine/server
Antoine Leblanc b4f7e96665 Rewrite GraphQL.Analysis
### Motivation

While we strive to write clear code, we have historically struggled at Hasura with having very different styles and standards across the codebase. There's been efforts to standardize our coding style, we have an official styleguide that isn't maintained as closely as it should... We still have some work in front of us.

However, in the last ~year or so, there's been a huge push towards incrementally improving the situation. As part of this we've been blocking PRs that don't add enough comments, or don't improve the files that they touch.

While looking at `Hasura.GraphQL.Analyse`, it became apparent that this file did not meet the engineering standards that I would expect to see addressed during a code review. Some ways in which I think it falls short:
- lack of documentation
- no clear distinction between public / internal components
- "unidiomatic" Haskell code (such as using `Either Result Error`)

While there's no problem with a file looking like this during development, those issues should have been caught at review time. The fact that they weren't indicates a problem in our process that we will need to address: code quality and maintainability is paramount, and we all need to do our part.

### Description

This PR rewrites all of `Hasura.GraphQL.Analyze`, and adapts `Hasura.Server.OpenAPI` accordingly where needed. I've attempted to clarify names and add documentation based on my understanding of the code, and to clean what was unused (such as field variables). I don't think this PR is good enough as is, and I welcome criticism where I got my comments wrong / am happy to help y'all add more.

This PR makes one small change in the way error messages are reported (and adjusts the corresponding test accordingly); each error message is now prefixed with the path within the selection set:
```
⚠️ $.test.foo.bar.baz.mizpelled: field 'mizpelled' not found in object 'Baz'
```

### Note

This PR is currently **on top of #3962**. You can preview the changes in isolation by [diffing the branches](https://github.com/hasura/graphql-engine-mono/compare/nicuveo/clean-rest-endpoint-inconsistency-check..nicuveo/rewrite-analysis).

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3963
Co-authored-by: paritosh-08 <85472423+paritosh-08@users.noreply.github.com>
GitOrigin-RevId: 5ec38e0e753f0c12096a350db0737658495e2f15
2022-04-04 05:54:59 +00:00
..
bench-wrk server, pro: actually reformat the code-base using ormolu 2021-09-23 22:57:37 +00:00
benchmarks ci: hide old benchmark reports for PRs with many comments 2022-02-24 20:09:17 +00:00
documentation server/tests: unify HASURA_BIGQUERY_SERVICE_KEY and HASURA_BIGQUERY_SERVICE_ACCOUNT env vars 2022-03-14 07:50:35 +00:00
packaging ci: add support for linux/arm64 docker image 2021-12-09 09:34:22 +00:00
src-exec Yeet some default-extensions 2022-03-16 00:40:17 +00:00
src-gdw-api Moved GDW API types into their own internal lib 2022-04-01 01:21:29 +00:00
src-lib Rewrite GraphQL.Analysis 2022-04-04 05:54:59 +00:00
src-rsr server: drop the dropping trigger logic while creating/recreating an event trigger 2022-04-01 10:39:35 +00:00
src-test Moved GDW API types into their own internal lib 2022-04-01 01:21:29 +00:00
tests-hspec server: document how to enable logging in hspec tests 2022-03-30 15:50:27 +00:00
tests-py Rewrite GraphQL.Analysis 2022-04-04 05:54:59 +00:00
.dockerignore update packages (#251) 2018-08-08 13:10:13 +05:30
.gitignore server/citus: feature branch 2021-05-21 02:47:51 +00:00
commit_diff.txt Rewrite GraphQL schema generation and query parsing (close #2801) (#4111) 2020-08-21 12:27:01 -05:00
COMPILING-ON-M1.md update contributing and compiling on m1 2022-01-21 11:21:49 +00:00
CONTRIBUTING.md server/gardening: move local hoogle setup from Makefile to bash script 2022-03-16 10:44:01 +00:00
graphql-engine.cabal server: Remove unused server tests 2022-04-01 09:38:54 +00:00
Makefile ci: misc. cleanup, naming 2022-01-03 06:26:39 +00:00
STYLE.md server, CI: use ormolu as a formatter for Haskell sources 2021-09-23 21:23:21 +00:00
testing-guidelines.md server: testing guidelines 2022-03-08 09:53:27 +00:00