Skip to content

Commit 574df36

Browse files
authored
fix(graphql-rpc): load empty object keys correctly (#9438)
# Description of change Avoids unfiltered queries when loading empty object keys. Currently the loaders are used correctly, but the fix makes the implementation more robust for future misuses. ## Links to any relevant issues Fixes #9400 ## How the change has been tested Describe the tests that you ran to verify your changes. Make sure to provide instructions for the maintainer as well as any relevant configurations. - [x] Basic tests (linting, compilation, formatting, unit/integration tests) - [ ] Patch-specific tests (correctness, functionality coverage) ### Infrastructure QA (only required for crates that are maintained by @iotaledger/infrastructure) - [ ] Synchronization of the indexer from genesis for a network including migration objects. - [ ] Restart of indexer synchronization locally without resetting the database. - [ ] Restart of indexer synchronization on a production-like database. - [ ] Deployment of services using Docker. - [x] Verification of API backward compatibility.
1 parent 7474a06 commit 574df36

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

crates/iota-graphql-rpc/src/types/object.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,10 @@ impl Loader<HistoricalKey> for Db {
13371337
use objects_history::dsl as h;
13381338
use objects_version::dsl as v;
13391339

1340+
if keys.is_empty() {
1341+
return Ok(HashMap::new());
1342+
}
1343+
13401344
let id_versions: BTreeSet<_> = keys
13411345
.iter()
13421346
.map(|key| (key.id.into_vec(), key.version as i64))
@@ -1405,6 +1409,10 @@ impl Loader<OptimisticKey> for Db {
14051409
async fn load(&self, keys: &[OptimisticKey]) -> Result<HashMap<OptimisticKey, Object>, Error> {
14061410
use objects::dsl as o;
14071411

1412+
if keys.is_empty() {
1413+
return Ok(HashMap::new());
1414+
}
1415+
14081416
let id_versions: BTreeSet<_> = keys
14091417
.iter()
14101418
.map(|key| (key.id.into_vec(), key.version as i64))

0 commit comments

Comments
 (0)