From 696e0148c19ea8cb3a390b0cc5eddcf901514eee Mon Sep 17 00:00:00 2001 From: araujobarret Date: Wed, 20 Nov 2024 09:51:45 +0100 Subject: [PATCH] feat: shallow partner and artist in Artwork data when possible --- .../ArtistArtworks/CreateArtworkAlertModal.tests.tsx | 7 ++++--- .../Artist/ArtistArtworks/CreateArtworkAlertModal.tsx | 4 ++-- src/app/Components/ArtworkGrids/ArtworkGridItem.tsx | 2 +- src/app/Components/ArtworkRail/ArtworkRailCardMeta.tsx | 2 +- .../ContextMenu/ContextMenuArtworkPreviewCard.tsx | 2 +- .../components/PartnerOfferCreatedNotification.tsx | 2 +- src/app/Scenes/Artwork/Artwork.tsx | 4 ++-- src/app/Scenes/Artwork/Components/AboutArtist.tsx | 4 ++-- .../Scenes/Artwork/Components/ArtworkConsignments.tsx | 2 +- src/app/Scenes/Artwork/Components/ArtworkHeader.tsx | 2 +- .../Components/ArtworkLotDetails/ArtworkLotDetails.tsx | 2 +- src/app/Scenes/Artwork/Components/ArtworkMakerTitle.tsx | 2 +- .../Components/ArtworkScreenHeaderCreateAlert.tsx | 2 +- .../Components/BrowseSimilarWorks/BrowseSimilarWorks.tsx | 2 +- src/app/Scenes/CollectionsByCategory/CollectionRail.tsx | 9 +++------ 15 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/app/Components/Artist/ArtistArtworks/CreateArtworkAlertModal.tests.tsx b/src/app/Components/Artist/ArtistArtworks/CreateArtworkAlertModal.tests.tsx index 1a5b46c9489..a4eecffd9b5 100644 --- a/src/app/Components/Artist/ArtistArtworks/CreateArtworkAlertModal.tests.tsx +++ b/src/app/Components/Artist/ArtistArtworks/CreateArtworkAlertModal.tests.tsx @@ -1,3 +1,4 @@ +import { screen } from "@testing-library/react-native" import { CreateArtworkAlertModal_artwork$data } from "__generated__/CreateArtworkAlertModal_artwork.graphql" import { CreateArtworkAlertModal, @@ -24,13 +25,13 @@ describe("CreateArtworkAlertModal", () => { }) it("returns null if artwork is ineligible", () => { - const { queryByText } = renderWithRelay({ + renderWithRelay({ Artwork: () => ({ isEligibleToCreateAlert: false, }), }) - expect(queryByText("CreateSavedSearchModal")).toBeFalsy() + expect(screen.queryByText("CreateSavedSearchModal")).toBeFalsy() }) it("returns renders modal", () => { @@ -50,7 +51,7 @@ describe("CreateArtworkAlertModal", () => { describe("computeArtworkAlertProps", () => { const artwork = { - artistsArray: [{ name: "foo", internalID: "bar" }], + artists: [{ name: "foo", internalID: "bar" }], isEligibleToCreateAlert: true, attributionClass: { internalID: "1", diff --git a/src/app/Components/Artist/ArtistArtworks/CreateArtworkAlertModal.tsx b/src/app/Components/Artist/ArtistArtworks/CreateArtworkAlertModal.tsx index 78b247daf50..3364000bd80 100644 --- a/src/app/Components/Artist/ArtistArtworks/CreateArtworkAlertModal.tsx +++ b/src/app/Components/Artist/ArtistArtworks/CreateArtworkAlertModal.tsx @@ -34,7 +34,7 @@ export const CreateArtworkAlertModal: React.FC = ( internalID slug isEligibleToCreateAlert - artistsArray: artists { + artists(shallow: true) { internalID name } @@ -92,7 +92,7 @@ export const computeArtworkAlertProps = ( let aggregations: Aggregations = [] let additionalGeneIDs: string[] = [] - const artists = compact(artwork?.artistsArray) + const artists = compact(artwork?.artists) const attributionClass = compact([artwork?.attributionClass?.internalID]) const formattedArtists: SavedSearchEntityArtist[] = artists.map((artist) => ({ id: artist.internalID, diff --git a/src/app/Components/ArtworkGrids/ArtworkGridItem.tsx b/src/app/Components/ArtworkGrids/ArtworkGridItem.tsx index 9c3f6f38b85..475f0d56e1e 100644 --- a/src/app/Components/ArtworkGrids/ArtworkGridItem.tsx +++ b/src/app/Components/ArtworkGrids/ArtworkGridItem.tsx @@ -539,7 +539,7 @@ export default createFragmentContainer(Artwork, { endAt extendedBiddingEndAt } - partner { + partner(shallow: true) { name } image(includeAll: $includeAllImages) { diff --git a/src/app/Components/ArtworkRail/ArtworkRailCardMeta.tsx b/src/app/Components/ArtworkRail/ArtworkRailCardMeta.tsx index 13850193c06..64cfeacfed7 100644 --- a/src/app/Components/ArtworkRail/ArtworkRailCardMeta.tsx +++ b/src/app/Components/ArtworkRail/ArtworkRailCardMeta.tsx @@ -272,7 +272,7 @@ const artworkMetaFragment = graphql` } } saleMessage - partner { + partner(shallow: true) { name } title diff --git a/src/app/Components/ContextMenu/ContextMenuArtworkPreviewCard.tsx b/src/app/Components/ContextMenu/ContextMenuArtworkPreviewCard.tsx index 3792f41d46b..7feff5b2776 100644 --- a/src/app/Components/ContextMenu/ContextMenuArtworkPreviewCard.tsx +++ b/src/app/Components/ContextMenu/ContextMenuArtworkPreviewCard.tsx @@ -145,7 +145,7 @@ const artworkFragment = graphql` endAt extendedBiddingEndAt } - partner { + partner(shallow: true) { name } } diff --git a/src/app/Scenes/Activity/components/PartnerOfferCreatedNotification.tsx b/src/app/Scenes/Activity/components/PartnerOfferCreatedNotification.tsx index 72991401d43..cd3ce4bb9f3 100644 --- a/src/app/Scenes/Activity/components/PartnerOfferCreatedNotification.tsx +++ b/src/app/Scenes/Activity/components/PartnerOfferCreatedNotification.tsx @@ -173,7 +173,7 @@ export const PartnerOfferCreatedNotificationFragment = graphql` edges { node { internalID - partner { + partner(shallow: true) { profile { icon { url(version: "square140") diff --git a/src/app/Scenes/Artwork/Artwork.tsx b/src/app/Scenes/Artwork/Artwork.tsx index 97b0aa4db88..3eb5737d708 100644 --- a/src/app/Scenes/Artwork/Artwork.tsx +++ b/src/app/Scenes/Artwork/Artwork.tsx @@ -732,7 +732,7 @@ export const ArtworkContainer = createRefetchContainer( type isInquireable } - artist { + artist(shallow: true) { biographyBlurb { text } @@ -774,7 +774,7 @@ export const ArtworkContainer = createRefetchContainer( } } } - artists { + artists(shallow: true) { isConsignable } isEligibleForArtsyGuarantee diff --git a/src/app/Scenes/Artwork/Components/AboutArtist.tsx b/src/app/Scenes/Artwork/Components/AboutArtist.tsx index 6b8e83d725b..a9bb9603a24 100644 --- a/src/app/Scenes/Artwork/Components/AboutArtist.tsx +++ b/src/app/Scenes/Artwork/Components/AboutArtist.tsx @@ -71,7 +71,7 @@ export const AboutArtistFragmentContainer = createFragmentContainer(AboutArtist, artwork: graphql` fragment AboutArtist_artwork on Artwork { displayArtistBio - artists { + artists(shallow: true) { id biographyBlurb { text @@ -79,7 +79,7 @@ export const AboutArtistFragmentContainer = createFragmentContainer(AboutArtist, ...ArtistListItem_artist } - artist { + artist(shallow: true) { partnerBiographyBlurb { text } diff --git a/src/app/Scenes/Artwork/Components/ArtworkConsignments.tsx b/src/app/Scenes/Artwork/Components/ArtworkConsignments.tsx index f5f571f4b5b..35839bd8b45 100644 --- a/src/app/Scenes/Artwork/Components/ArtworkConsignments.tsx +++ b/src/app/Scenes/Artwork/Components/ArtworkConsignments.tsx @@ -48,7 +48,7 @@ export const ArtworkConsignments: React.FC = ({ artwor const artworkConsignmentsFragment = graphql` fragment ArtworkConsignments_artwork on Artwork { - artists { + artists(shallow: true) { isConsignable name } diff --git a/src/app/Scenes/Artwork/Components/ArtworkHeader.tsx b/src/app/Scenes/Artwork/Components/ArtworkHeader.tsx index 501303be100..454d65c2e09 100644 --- a/src/app/Scenes/Artwork/Components/ArtworkHeader.tsx +++ b/src/app/Scenes/Artwork/Components/ArtworkHeader.tsx @@ -141,7 +141,7 @@ export const ArtworkHeaderFragmentContainer = createFragmentContainer(ArtworkHea internalID slug visibilityLevel - artists { + artists(shallow: true) { name } partner { diff --git a/src/app/Scenes/Artwork/Components/ArtworkLotDetails/ArtworkLotDetails.tsx b/src/app/Scenes/Artwork/Components/ArtworkLotDetails/ArtworkLotDetails.tsx index 182ccd81ec7..aaed6de5c91 100644 --- a/src/app/Scenes/Artwork/Components/ArtworkLotDetails/ArtworkLotDetails.tsx +++ b/src/app/Scenes/Artwork/Components/ArtworkLotDetails/ArtworkLotDetails.tsx @@ -119,7 +119,7 @@ const artworkFragment = graphql` fragment ArtworkLotDetails_artwork on Artwork { isForSale title - artist { + artist(shallow: true) { name } sale { diff --git a/src/app/Scenes/Artwork/Components/ArtworkMakerTitle.tsx b/src/app/Scenes/Artwork/Components/ArtworkMakerTitle.tsx index fbaba1c4bd4..4eda8d0f324 100644 --- a/src/app/Scenes/Artwork/Components/ArtworkMakerTitle.tsx +++ b/src/app/Scenes/Artwork/Components/ArtworkMakerTitle.tsx @@ -111,7 +111,7 @@ export const ArtworkMakerTitleFragmentContainer = createFragmentContainer(Artwor artwork: graphql` fragment ArtworkMakerTitle_artwork on Artwork { culturalMaker - artists { + artists(shallow: true) { name href } diff --git a/src/app/Scenes/Artwork/Components/ArtworkScreenHeaderCreateAlert.tsx b/src/app/Scenes/Artwork/Components/ArtworkScreenHeaderCreateAlert.tsx index 2785625d9a5..6a9bc611b3d 100644 --- a/src/app/Scenes/Artwork/Components/ArtworkScreenHeaderCreateAlert.tsx +++ b/src/app/Scenes/Artwork/Components/ArtworkScreenHeaderCreateAlert.tsx @@ -58,7 +58,7 @@ const ArtworkScreenHeaderCreateAlert_artwork = graphql` isEligibleToCreateAlert isInAuction ...CreateArtworkAlertModal_artwork - artists { + artists(shallow: true) { internalID } isForSale diff --git a/src/app/Scenes/Artwork/Components/BrowseSimilarWorks/BrowseSimilarWorks.tsx b/src/app/Scenes/Artwork/Components/BrowseSimilarWorks/BrowseSimilarWorks.tsx index 115514bcc0c..df0111c24fc 100644 --- a/src/app/Scenes/Artwork/Components/BrowseSimilarWorks/BrowseSimilarWorks.tsx +++ b/src/app/Scenes/Artwork/Components/BrowseSimilarWorks/BrowseSimilarWorks.tsx @@ -92,7 +92,7 @@ const similarWorksFragment = graphql` internalID slug isEligibleToCreateAlert - artistsArray: artists { + artists(shallow: true) { internalID name } diff --git a/src/app/Scenes/CollectionsByCategory/CollectionRail.tsx b/src/app/Scenes/CollectionsByCategory/CollectionRail.tsx index 00a7a9f5461..a049b60d072 100644 --- a/src/app/Scenes/CollectionsByCategory/CollectionRail.tsx +++ b/src/app/Scenes/CollectionsByCategory/CollectionRail.tsx @@ -32,12 +32,12 @@ export const CollectionRail: FC = ({ const collection = useFragment(fragment, _collection) const { trackArtworkRailItemTap, trackArtworkRailViewAllTap } = useCollectionByCategoryTracking() - if (!collection || collection.artworksConnection?.counts.total === 0) { + const artworks = extractNodes(collection?.artworksConnection) + + if (!collection || !artworks.length) { return null } - const artworks = extractNodes(collection.artworksConnection) - const handleArtworkPress = (artwork: ArtworkRail_artworks$data[0], index: number) => { trackArtworkRailItemTap(artwork.internalID, index) navigate(artwork.href ?? "") @@ -89,9 +89,6 @@ const fragment = graphql` slug @required(action: NONE) artworksConnection(first: 10, sort: "-decayed_merch") { - counts @required(action: NONE) { - total - } edges { node { ...ArtworkRail_artworks