hasura / hasura/graphql-engine

server/refactor: use `Set`/`HashSet` to deduplicate function names in `runTxWithMetadataCheck`

Open
#8,888 4 comments 0 reactions 0 assignees View on GitHub
c/server
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

The root cause of [graphql-engine#8643: Migrations fail if duplicate functions exist](https://github.com/hasura/graphql-engine/issues/8643) is that the list of functions to consider for metadata diff checks ends up with duplicates when a function is tracked both as root field and as computed field:

https://github.com/hasura/graphql-engine/blob/f80ec1d543e0e3e4711fe72bb8f19c097e6897c1/server/src-lib/Hasura/Backends/Postgres/DDL/RunSQL.hs#L303

The proper fix is to ensure that we use [sets](https://hackage.haskell.org/package/containers-0.6.6/docs/Data-Set.html)/[hashsets](https://hackage.haskell.org/package/unordered-containers-0.2.19.1/docs/Data-HashSet.html) in all the functions involved instead of lists in order to statically ensure no duplicates appear by accident.

Contributor guide

Open the contributing guide

Research direction

Start with server/src-lib/Hasura/Backends/Postgres/DDL/RunSQL.hs around the linked line and trace runTxWithMetadataCheck plus the functions that assemble its function list. Confirm the duplicate root-field/computed-field case from graphql-engine#8643, then verify that the affected paths use sets and that migrations with duplicate functions no longer fail.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, postgresql
Domain
backend, databases
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.