graphql-engine/server
Antoine Leblanc 3a400fab3d Rewrite OpenAPI
### Description

This PR rewrites OpenAPI to be more idiomatic. Some noteworthy changes:
- we accumulate all required information during the Analyze phase, to avoid having to do a single lookup in the schema cache during the OpenAPI generation phase (we now only need the schema cache as input to run the analysis)
- we no longer build intermediary endpoint information and aggregate it, we directly build the the `PathItem` for each endpoint; additionally, that means we no longer have to assume that different methods have the same metadata
- we no longer have to first declare types, then craft references: we do everything in one step
- we now properly deal with nullability by treating "typeName" and "typeName!" as different
- we add a bunch of additional fields in the generated "schema", such as title
- we do now support enum values in both input and output positions
- checking whether the request body is required is now performed on the fly rather than by introspecting the generated schema
- the methods in the file are sorted by topic

### Controversial point

However, this PR creates some additional complexity, that we might not want to keep. The main complexity is _knot-tying_: to avoid lookups when generating the OpenAPI, it builds an actual graph of input types, which means that we need something similar to (but simpler than) `MonadSchema`, to avoid infinite recursions when analyzing the input types of a query. To do this, this PR introduces `CircularT`, a lesser `SchemaT` that aims at avoiding ever having to reinvent this particular wheel ever again.

### Remaining work

- [x] fix existing tests (they are all failing due to some of the schema changes)
- [ ] add tests to cover the new features:
  - [x] tests for `CircularT`
  - [ ] tests for enums in output schemas
- [x] extract / document `CircularT` if we wish to keep it
- [x] add more comments to `OpenAPI`
- [x] have a second look at `buildVariableSchema`
- [x] fix all missing diagnostics in `Analyze`
- [x] add a Changelog entry?

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4654
Co-authored-by: David Overton <7734777+dmoverton@users.noreply.github.com>
GitOrigin-RevId: f4a9191f22dfcc1dccefd6a52f5c586b6ad17172
2022-06-30 12:57:09 +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/postgres: test identifier uniqueness rewrite 2022-06-17 10:44:18 +00:00
src-dc-api Added a healthcheck endpoint to the Data Connector Agent API spec 2022-06-30 08:37:53 +00:00
src-emit-metadata-openapi server: initial set of DTO types for metadata 2022-06-27 16:33:31 +00:00
src-exec Remove RQL/Types.hs 2022-04-27 13:58:47 +00:00
src-lib Rewrite OpenAPI 2022-06-30 12:57:09 +00:00
src-rsr ci: tag release v2.8.3 2022-06-30 10:57:25 +00:00
src-test Rewrite OpenAPI 2022-06-30 12:57:09 +00:00
tests-dc-api Added a healthcheck endpoint to the Data Connector Agent API spec 2022-06-30 08:37:53 +00:00
tests-hspec Port the "test_user_perms" pytest to hspec 2022-06-30 10:28:08 +00:00
tests-py Rewrite OpenAPI 2022-06-30 12:57:09 +00:00
.dockerignore update packages (#251) 2018-08-08 13:10:13 +05:30
.gitignore server: Clean up Cabal project files 2022-04-07 07:16:12 +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-MACOS.md tooling: Opt-in shared tooling 2022-06-16 17:12:35 +00:00
CONTRIBUTING.md tooling: Opt-in shared tooling 2022-06-16 17:12:35 +00:00
graphql-engine.cabal Rewrite OpenAPI 2022-06-30 12:57:09 +00:00
Makefile ci: misc. cleanup, naming 2022-01-03 06:26:39 +00:00
STYLE.md Nix: Use nixpkgs-fmt to format everything. 2022-06-20 13:02:45 +00:00
testing-guidelines.md server: testing guidelines 2022-03-08 09:53:27 +00:00
troubleshooting.md Create troubleshooting.md 2022-05-30 09:18:44 +00:00