mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
3d5fb984b0
## Description There is a bug in the metadata defaults code, see [the original PR](https://github.com/hasura/graphql-engine-mono/pull/6286). Steps to reproduce this issue: * Start a new HGE project * Start HGE with a defaults argument: `HASURA_GRAPHQL_LOG_LEVEL=debug cabal run exe:graphql-engine -- serve --enable-console --console-assets-dir=./console/static/dist --metadata-defaults='{"backend_configs": {"dataconnector": {"mongo": {"display_name": "BONGOBB", "uri": "http://localhost:8123"}}}}'` * Add a source (doesn't need to be related to the defaults) * Export metadata * See that the defaults are present in the exported metadata ## Related Issues * Github Issue: https://github.com/hasura/graphql-engine/issues/9237 * Jira: https://hasurahq.atlassian.net/browse/GDC-647 * Original PR: https://github.com/hasura/graphql-engine-mono/pull/6286 ## Solution * The test for if defaults should be included for metadata api operations has been extended to check for updates * Metadata inconsistencies have been hidden for `/capabilities` calls on startup ## TODO * [x] Fix bug * [x] Write tests * [x] OSS Metadata Migration to correct persisted data - `server/src-rsr/migrations/47_to_48.sql` * [x] Cloud Metadata Migration - `pro/server/res/cloud/migrations/6_to_7.sql` * [x] Bump Catalog Version - `server/src-rsr/catalog_version.txt` * [x] Update Catalog Versions - `server/src-rsr/catalog_versions.txt` (This will be done by Infra when creating a release) * [x] Log connection error as it occurs *(Already being logged. Requires `--enabled-log-types startup,webhook-log,websocket-log,http-log,data-connector-log`) * [x] Don't mark metadata inconsistencies for this call. ## Questions * [ ] Does the `pro/server/res/cloud/migrations/6_to_7.sql` cover the cloud scenarios? * [ ] Should we have `SET search_path` in migrations? * [x] What should be in `server/src-rsr/catalog_versions.txt`? ## Testing To test the solution locally run: > docker compose up -d and > cabal run -- exe:api-tests --skip BigQuery --skip SQLServer --skip '/Test.API.Explain/Postgres/' ## Solution In `runMetadataQuery` in `server/src-lib/Hasura/Server/API/Metadata.hs`: ```diff - if (exportsMetadata _rqlMetadata) + if (exportsMetadata _rqlMetadata || queryModifiesMetadata _rqlMetadata) ``` This ensures that defaults aren't present in operations that serialise metadata. Note: You might think that `X_add_source` would need the defaults to be present to add a source that references the defaults, but since the resolution occurs in the schema-cache building phase, the defaults can be excluded for the metadata modifications required for `X_add_source`. In addition to the code-change, a metadata migration has been introduced in order to clean up serialised defaults. The following scenarios need to be considered for both OSS and Cloud: * The user has not had defaults serialised * The user has had the defaults serialised and no other backends configured * The user has had the defaults serialised and has also configured other backends We want to remove as much of the metadata as possible without any user-specified data and this should be reflected in migration `server/src-rsr/migrations/47_to_48.sql`. ## Server checklist ### Catalog upgrade Does this PR change Hasura Catalog version? - ✅ Yes ### Metadata Does this PR add a new Metadata feature? - ✅ No ### GraphQL - ✅ No new GraphQL schema is generated ### Breaking changes - ✅ No Breaking changes ## Changelog __Component__ : server __Type__: bugfix __Product__: community-edition ### Short Changelog Fixes a metadata defaults serialization bug and introduces a metadata migration to correct data that has been persisted due to the bug. PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7034 GitOrigin-RevId: ad7d4f748397a1a607f2c0c886bf0fbbc3f873f2 |
||
---|---|---|
.. | ||
1_to_2.sql | ||
2_to_3.sql | ||
4_to_5.sql | ||
5_to_6.sql | ||
6_to_7.sql | ||
7_to_8.sql | ||
8_to_9.sql | ||
9_to_10.sql | ||
08_to_1.sql | ||
10_to_11.sql | ||
11_to_12.sql | ||
12_to_13.sql | ||
13_to_12.sql | ||
13_to_14.sql | ||
14_to_13.sql | ||
14_to_15.sql | ||
15_to_14.sql | ||
15_to_16.sql | ||
16_to_15.sql | ||
16_to_17.sql | ||
17_to_16.sql | ||
17_to_18.sql | ||
18_to_17.sql | ||
18_to_19.sql | ||
19_to_18.sql | ||
19_to_20.sql | ||
20_to_19.sql | ||
20_to_21.sql | ||
21_to_20.sql | ||
21_to_22.sql | ||
22_to_21.sql | ||
22_to_23.sql | ||
23_to_22.sql | ||
23_to_24.sql | ||
24_to_23.sql | ||
24_to_25.sql | ||
25_to_24.sql | ||
25_to_26.sql | ||
26_to_25.sql | ||
26_to_27.sql | ||
27_to_26.sql | ||
27_to_28.sql | ||
28_to_27.sql | ||
28_to_29.sql | ||
29_to_28.sql | ||
29_to_30.sql | ||
30_to_29.sql | ||
30_to_31.sql | ||
31_to_30.sql | ||
31_to_32.sql | ||
32_to_31.sql | ||
32_to_33.sql | ||
33_to_32.sql | ||
33_to_34.sql | ||
34_to_33.sql | ||
34_to_35.sql | ||
35_to_34.sql | ||
35_to_36.sql | ||
36_to_35.sql | ||
36_to_37.sql | ||
37_to_36.sql | ||
37_to_38.sql | ||
38_to_37.sql | ||
38_to_39.sql | ||
39_to_38.sql | ||
39_to_40.sql | ||
40_to_39.sql | ||
41_to_40.sql | ||
41_to_42.sql | ||
42_to_41.sql | ||
42_to_43.sql | ||
43_to_42.sql | ||
43_to_44.sql | ||
44_to_43.sql | ||
44_to_45.sql | ||
45_to_44.sql | ||
45_to_46.sql | ||
46_to_45.sql | ||
46_to_47.sql | ||
47_to_46.sql | ||
47_to_48.sql | ||
48_to_47.sql |