Skip to content

Commit

Permalink
Merge pull request #5978 from artsy/cover-artwork-fallback
Browse files Browse the repository at this point in the history
chore: allow a missing _or_ unpublished cover artwork to fallback on Artist
  • Loading branch information
mzikherman authored Sep 5, 2024
2 parents 62fb361 + c554b1a commit 53e17e3
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/schema/v2/artist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,22 +696,23 @@ export const ArtistType = new GraphQLObjectType<any, ResolverContext>({
_options,
{ artistArtworksLoader, artworkLoader }
) => {
try {
if (cover_artwork_id) {
return artworkLoader(cover_artwork_id)
if (cover_artwork_id) {
try {
return await artworkLoader(cover_artwork_id)
} catch {
// Intentionally ignore errors from unpublished/deleted artworks
// that are set as cover artworks.
}
}

const [fallbackArtwork] = await artistArtworksLoader(id, {
offset: 0,
size: 1,
sort: "-iconicity",
published: true,
})
const [fallbackArtwork] = await artistArtworksLoader(id, {
offset: 0,
size: 1,
sort: "-iconicity",
published: true,
})

return fallbackArtwork
} catch (error) {
return null
}
return fallbackArtwork
},
},
createdAt: date(),
Expand Down

0 comments on commit 53e17e3

Please sign in to comment.