Skip to content

Commit

Permalink
feat: shallow partner and artist in Artwork data when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
araujobarret committed Nov 21, 2024
1 parent 714f5df commit 696e014
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { screen } from "@testing-library/react-native"
import { CreateArtworkAlertModal_artwork$data } from "__generated__/CreateArtworkAlertModal_artwork.graphql"
import {
CreateArtworkAlertModal,
Expand All @@ -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", () => {
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const CreateArtworkAlertModal: React.FC<CreateArtworkAlertModalProps> = (
internalID
slug
isEligibleToCreateAlert
artistsArray: artists {
artists(shallow: true) {
internalID
name
}
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/app/Components/ArtworkGrids/ArtworkGridItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ export default createFragmentContainer(Artwork, {
endAt
extendedBiddingEndAt
}
partner {
partner(shallow: true) {
name
}
image(includeAll: $includeAllImages) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/Components/ArtworkRail/ArtworkRailCardMeta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ const artworkMetaFragment = graphql`
}
}
saleMessage
partner {
partner(shallow: true) {
name
}
title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const artworkFragment = graphql`
endAt
extendedBiddingEndAt
}
partner {
partner(shallow: true) {
name
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export const PartnerOfferCreatedNotificationFragment = graphql`
edges {
node {
internalID
partner {
partner(shallow: true) {
profile {
icon {
url(version: "square140")
Expand Down
4 changes: 2 additions & 2 deletions src/app/Scenes/Artwork/Artwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ export const ArtworkContainer = createRefetchContainer(
type
isInquireable
}
artist {
artist(shallow: true) {
biographyBlurb {
text
}
Expand Down Expand Up @@ -774,7 +774,7 @@ export const ArtworkContainer = createRefetchContainer(
}
}
}
artists {
artists(shallow: true) {
isConsignable
}
isEligibleForArtsyGuarantee
Expand Down
4 changes: 2 additions & 2 deletions src/app/Scenes/Artwork/Components/AboutArtist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ export const AboutArtistFragmentContainer = createFragmentContainer(AboutArtist,
artwork: graphql`
fragment AboutArtist_artwork on Artwork {
displayArtistBio
artists {
artists(shallow: true) {
id
biographyBlurb {
text
}
...ArtistListItem_artist
}
artist {
artist(shallow: true) {
partnerBiographyBlurb {
text
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/Scenes/Artwork/Components/ArtworkConsignments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const ArtworkConsignments: React.FC<ArtworkConsignmentsProps> = ({ artwor

const artworkConsignmentsFragment = graphql`
fragment ArtworkConsignments_artwork on Artwork {
artists {
artists(shallow: true) {
isConsignable
name
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/Scenes/Artwork/Components/ArtworkHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const ArtworkHeaderFragmentContainer = createFragmentContainer(ArtworkHea
internalID
slug
visibilityLevel
artists {
artists(shallow: true) {
name
}
partner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const artworkFragment = graphql`
fragment ArtworkLotDetails_artwork on Artwork {
isForSale
title
artist {
artist(shallow: true) {
name
}
sale {
Expand Down
2 changes: 1 addition & 1 deletion src/app/Scenes/Artwork/Components/ArtworkMakerTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const ArtworkMakerTitleFragmentContainer = createFragmentContainer(Artwor
artwork: graphql`
fragment ArtworkMakerTitle_artwork on Artwork {
culturalMaker
artists {
artists(shallow: true) {
name
href
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const ArtworkScreenHeaderCreateAlert_artwork = graphql`
isEligibleToCreateAlert
isInAuction
...CreateArtworkAlertModal_artwork
artists {
artists(shallow: true) {
internalID
}
isForSale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const similarWorksFragment = graphql`
internalID
slug
isEligibleToCreateAlert
artistsArray: artists {
artists(shallow: true) {
internalID
name
}
Expand Down
9 changes: 3 additions & 6 deletions src/app/Scenes/CollectionsByCategory/CollectionRail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export const CollectionRail: FC<CollectionRailProps> = ({
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 ?? "")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 696e014

Please sign in to comment.