diff --git a/schema.gql b/schema.gql index 5d508b87e..0d76bde57 100644 --- a/schema.gql +++ b/schema.gql @@ -211,6 +211,7 @@ input AssetsFilter { identifiers: [String!] likedByAddress: String ownerAddress: String + searchTerm: String tags: [String!] traits: [NftTrait] type: NftTypeEnum diff --git a/src/modules/assets/assets-getter.service.ts b/src/modules/assets/assets-getter.service.ts index 276fd60bc..8bde89ff9 100644 --- a/src/modules/assets/assets-getter.service.ts +++ b/src/modules/assets/assets-getter.service.ts @@ -42,7 +42,7 @@ export class AssetsGetterService { ) {} async getAssetsForUser(address: string, query: string = '', countQuery: string = ''): Promise> { - query = new AssetsQuery(query).addQuery('includeFlagged=true&source=elastic').build(); + query = new AssetsQuery(query).addQuery('includeFlagged=true').build(); countQuery = new AssetsQuery(countQuery).addQuery('includeFlagged=true').build(); const [nfts, count] = await Promise.all([ this.apiService.getNftsForUser(address, query), @@ -273,6 +273,7 @@ export class AssetsGetterService { .addCollection(filters?.collection) .addCollections(filters?.collections) .addType(filters?.type) + .addSearchTerm(filters?.searchTerm) .withOwner() .withSupply() .addPageSize(offset, limit) @@ -287,6 +288,7 @@ export class AssetsGetterService { .addCollection(filters?.collection) .addCollections(filters?.collections) .addType(filters?.type) + .addSearchTerm(filters?.searchTerm) .withSupply() .addPageSize(offset, limit) .build(); diff --git a/src/modules/common/filters/filtersTypes.ts b/src/modules/common/filters/filtersTypes.ts index dcf17d223..0064c40d1 100644 --- a/src/modules/common/filters/filtersTypes.ts +++ b/src/modules/common/filters/filtersTypes.ts @@ -1,5 +1,5 @@ import { Field, InputType, registerEnumType } from '@nestjs/graphql'; -import { IsOptional, Matches } from 'class-validator'; +import { IsOptional, Matches, MinLength } from 'class-validator'; import { NftTrait } from 'src/modules/nft-traits/models/nft-traits.model'; import { ADDRESS_ERROR, @@ -185,6 +185,12 @@ export class AssetsFilter { @Field(() => [NftTrait], { nullable: 'itemsAndList' }) traits: NftTrait[]; + @Field(() => String, { nullable: true }) + @MinLength(3, { + message: 'The search term should contain at least 3 characters', + }) + searchTerm: string; + constructor(init?: Partial) { Object.assign(this, init); }