diff --git a/components/Filter/FilterBy/Trait.tsx b/components/Filter/FilterBy/Trait.tsx index 9452817b..782df787 100644 --- a/components/Filter/FilterBy/Trait.tsx +++ b/components/Filter/FilterBy/Trait.tsx @@ -65,8 +65,8 @@ const FilterByTrait: FC = ({ notifyOnNetworkStatusChange: true, }) - const traitsData = data?.collection?.traitsOfCollection.nodes - const hasNextPage = data?.collection?.traitsOfCollection.pageInfo.hasNextPage + const traitsData = data?.collectionTraits?.nodes + const hasNextPage = data?.collectionTraits?.pageInfo.hasNextPage const loadMore = useCallback(async () => { const newOffset = offset + PAGINATION_LIMIT @@ -76,22 +76,16 @@ const FilterByTrait: FC = ({ // Cannot use concatToQuery function because of nested cache // Nested cache comes from the shape of FetchCollectionTraits query above updateQuery: (prevResult, { fetchMoreResult }) => { - if ( - !fetchMoreResult || - !fetchMoreResult.collection?.traitsOfCollection - ) + if (!fetchMoreResult || !fetchMoreResult.collectionTraits) return prevResult return { ...fetchMoreResult, - collection: { - ...fetchMoreResult.collection, - traitsOfCollection: { - ...fetchMoreResult.collection.traitsOfCollection, - nodes: [ - ...(prevResult?.collection?.traitsOfCollection.nodes || []), - ...fetchMoreResult.collection.traitsOfCollection.nodes, - ], - }, + collectionTraits: { + ...fetchMoreResult.collectionTraits, + nodes: [ + ...(prevResult?.collectionTraits?.nodes || []), + ...fetchMoreResult.collectionTraits.nodes, + ], }, } }, diff --git a/hooks/useFetchCollectionTraits.gql b/hooks/useFetchCollectionTraits.gql index bed95bfe..a37ab5c6 100644 --- a/hooks/useFetchCollectionTraits.gql +++ b/hooks/useFetchCollectionTraits.gql @@ -1,33 +1,33 @@ query FetchCollectionTraits( $chainId: Int! $address: Address! - $filter: CollectionTraitFilter! + $filter: [CollectionTraitFilter!] $limit: Int! $offset: Int! ) { - collection(chainId: $chainId, address: $address) { - chainId - address - traitsOfCollection( - orderBy: [TYPE_ASC] - first: $limit - filter: $filter - offset: $offset - ) { - pageInfo { - hasNextPage - } - nodes { - type - numberOfValues - values( - first: 50 # TODO: implement pagination - orderBy: [NUMBER_OF_ASSETS_DESC, VALUE_ASC] - ) { - nodes { - value - numberOfAssets - } + collectionTraits( + orderBy: [TYPE_ASC] + first: $limit + filter: { + chainId: { equalTo: $chainId } + collectionAddress: { equalTo: $address } + and: $filter + } + offset: $offset + ) { + pageInfo { + hasNextPage + } + nodes { + type + numberOfValues + values( + first: 50 # TODO: implement pagination + orderBy: [NUMBER_OF_ASSETS_DESC, VALUE_ASC] + ) { + nodes { + value + numberOfAssets } } }