graphql-engine/server/src-lib/Hasura
Antoine Leblanc eaba2e08d3 Clean Relay's code, break schema cycles, introduce Node ID V2
## Motivation

This PR rewrites most of Relay to achieve the following:
- ~~fix a bug in which the same node id could refer to two different tables in the schema~~
- remove one of the few remaining uses of the source cache in the schema building code

In doing so, it also:
- simplifies the `BackendSchema` class by removing `node` from it,
- makes it much easier for other backends to support Relay,
- documents, re-organizes, and clarifies the code.

## Description

This PR introduces a new `NodeId` version ~~, and adapts the Postgres code to always generate this V2 version~~. This new id contains the source name, in addition to the table name, in order to disambiguate similar table names across different sources (which is now possible with source customization). In doing so, it now explicitly handles that case for V1 node ids, and returns an explicit error message instead of running the risk of _silently returning the wrong information_.

Furthermore, it adapts `nodeField` to support multiple backends; most of the code was trivial to generalize, and as a result it lowers the cost of entry for other backends, that now only need to support `AFNodeId` in their translation layer.

Finally, it removes one more cycle in the schema building code, by using the same trick we used for remote relationships instead of using the memoization trick of #4576.

## Remaining work

- ~~[ ]write a Changelog entry~~
- ~~[x] adapt all tests that were asserting on an old node id~~

## Future work

This PR was adapted from its original form to avoid a breaking change: while it introduces a Node ID V2, we keep generating V1 IDs and the parser rejects V2 IDs. It will be easy to make the switch at a later data in a subsequent PR.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4593
GitOrigin-RevId: 88e5cb91e8b0646900547fa8c7c0e1463de267a1
2022-06-07 13:36:29 +00:00
..
Backends Clean Relay's code, break schema cycles, introduce Node ID V2 2022-06-07 13:36:29 +00:00
Base Add Weeder, begin weeding (1/?) 2022-05-31 15:43:34 +00:00
Cache server, pro: actually reformat the code-base using ormolu 2021-09-23 22:57:37 +00:00
Eventing server: do not serialize env vars in logs or errors: PR III - Event Triggers 2022-06-05 20:28:13 +00:00
GraphQL Clean Relay's code, break schema cycles, introduce Node ID V2 2022-06-07 13:36:29 +00:00
Incremental server: disable query/subscription root fields 2022-06-07 05:33:12 +00:00
Metadata server: log details of healthcheck failure 2022-06-07 11:24:20 +00:00
RQL Clean Relay's code, break schema cycles, introduce Node ID V2 2022-06-07 13:36:29 +00:00
Server server: log details of healthcheck failure 2022-06-07 11:24:20 +00:00
SQL Add Weeder, begin weeding (1/?) 2022-05-31 15:43:34 +00:00
App.hs server: log details of healthcheck failure 2022-06-07 11:24:20 +00:00
EncJSON.hs Fix JSON encoding issue (fix hasura/graphql-engine#7543 and hasura/graphql-engine#8200) 2022-04-05 19:11:30 +00:00
GC.hs server: add explicit export lists in OSS server and enforce with warning 2021-11-04 16:09:38 +00:00
HTTP.hs server: http ip blocklist (closes #2449) 2022-02-25 13:30:57 +00:00
Incremental.hs server, pro: actually reformat the code-base using ormolu 2021-09-23 22:57:37 +00:00
Logging.hs Yeet some default-extensions 2022-03-16 00:40:17 +00:00
Prelude.hs Add Weeder, begin weeding (1/?) 2022-05-31 15:43:34 +00:00
QueryTags.hs server: support query tags for MSSQL data sources 2022-04-28 19:34:45 +00:00
Session.hs Add remote relationships from remote schemas in schema parser generators 2022-03-14 16:22:50 +00:00
Tracing.hs server: Clean up some deriving statements 2022-05-24 07:22:55 +00:00