graphql-engine/server
Auke Booij 8ccf7724ce server: Metadata origin for definitions (type parameter version v2)
The code that builds the GraphQL schema, and `buildGQLContext` in particular, is partial: not every value of `(ServerConfigCtx, GraphQLQueryType, SourceCache, HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject), ActionCache, AnnotatedCustomTypes)` results in a valid GraphQL schema. When it fails, we want to be able to return better error messages than we currently do.

The key thing that is missing is a way to trace back GraphQL type information to their origin from the Hasura metadata. Currently, we have a number of correctness checks of our GraphQL schema. But these correctness checks only have access to pure GraphQL type information, and hence can only report errors in terms of that. Possibly the worst is the "conflicting definitions" error, which, in practice, can only be debugged by Hasura engineers. This is terrible DX for customers.

This PR allows us to print better error messages, by adding a field to the `Definition` type that traces the GraphQL type to its origin in the metadata. So the idea is simple: just add `MetadataObjId`, or `Maybe` that, or some other sum type of that, to `Definition`.

However, we want to avoid having to import a `Hasura.RQL` module from `Hasura.GraphQL.Parser`. So we instead define this additional field of `Definition` through a new type parameter, which is threaded through in `Hasura.GraphQL.Parser`. We then define type synonyms in `Hasura.GraphQL.Schema.Parser` that fill in this type parameter, so that it is not visible for the majority of the codebase.

The idea of associating metadata information to `Definition`s really comes to fruition when combined with hasura/graphql-engine-mono#4517. Their combination would allow us to use the API of fatal errors (just like the current `MonadError QErr`) to report _inconsistencies_ in the metadata. Such inconsistencies are then _automatically_ ignored. So no ad-hoc decisions need to be made on how to cut out inconsistent metadata from the GraphQL schema. This will allow us to report much better errors, as well as improve the likelihood of a successful HGE startup.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4770
Co-authored-by: Samir Talwar <47582+SamirTalwar@users.noreply.github.com>
GitOrigin-RevId: 728402b0cae83ae8e83463a826ceeb609001acae
2022-06-28 15:53:44 +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 server: GHC 9.2 changes compatible with 8.10 (#3550) 2022-06-25 22:09:05 +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 server: Metadata origin for definitions (type parameter version v2) 2022-06-28 15:53:44 +00:00
src-rsr console: Hide timescaledb internal schema from data tab 2022-06-22 07:38:38 +00:00
src-test server: Metadata origin for definitions (type parameter version v2) 2022-06-28 15:53:44 +00:00
tests-dc-api AVRelationship Support for Data Connectors [GDW-123] 2022-06-24 06:59:52 +00:00
tests-hspec server: Create the BigQuery test tables and data in one go. 2022-06-28 08:40:33 +00:00
tests-py server: Metadata origin for definitions (type parameter version v2) 2022-06-28 15:53:44 +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 server: Metadata origin for definitions (type parameter version v2) 2022-06-28 15:53:44 +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