Skip to content

Commit

Permalink
[!] controller/tigergraphql/identity_graph: lowercase all category
Browse files Browse the repository at this point in the history
  • Loading branch information
nykma committed Apr 26, 2024
1 parent efd998d commit 5bdb77d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
22 changes: 18 additions & 4 deletions src/controller/tigergraphql/identity_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::{
};
use async_graphql::{Context, Object};
use dataloader::non_cached::Loader;
use std::str::FromStr;
use tracing::{event, Level};
use uuid::Uuid;

Expand Down Expand Up @@ -205,9 +206,9 @@ impl ExpandIdentityRecord {
&self,
_ctx: &Context<'_>,
#[graphql(
desc = "Filter condition for ContractCategory. If not provided or empty array, all category NFTs will be returned."
desc = "Filter condition for ContractCategory. If missing or empty, all category NFTs will be returned."
)]
category: Option<Vec<ContractCategory>>,
category: Option<Vec<String>>,
#[graphql(
desc = "`limit` used to control the maximum number of records returned by query. It defaults to 100"
)]
Expand All @@ -218,8 +219,21 @@ impl ExpandIdentityRecord {
offset: Option<u16>,
) -> Result<Vec<HoldRecord>> {
let client = make_http_client();
self.nfts(&client, category, limit.unwrap_or(100), offset.unwrap_or(0))
.await
let parsed_category: Option<Vec<ContractCategory>> = category.map(|orig| {
orig.into_iter()
.map(|c| {
ContractCategory::from_str(&c.to_lowercase())
.unwrap_or(ContractCategory::Unknown) // TODO: maybe error message is missing here.
})
.collect()
});
self.nfts(
&client,
parsed_category,
limit.unwrap_or(100),
offset.unwrap_or(0),
)
.await
}

async fn owner_address(&self) -> Option<Vec<Address>> {
Expand Down
1 change: 0 additions & 1 deletion src/upstream/types/contract_category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use strum_macros::{Display, EnumIter, EnumString};
async_graphql::Enum,
Hash,
)]
#[graphql(rename_items = "lowercase")]
pub enum ContractCategory {
#[strum(serialize = "ens")]
#[serde(rename = "ens")]
Expand Down

0 comments on commit 5bdb77d

Please sign in to comment.