Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hack-15): activity panel notification for saved artwork price or availability changes #6385

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions _schemaV2.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -12655,6 +12655,16 @@ enum MarketingCollectionGroupTypeEnum {
OtherCollections
}

type MarketingCollectionHitNotificationItem {
artworksConnection(
after: String
before: String
first: Int
last: Int
): ArtworkConnection
marketingCollection: MarketingCollection
}

type MarketingCollectionQuery {
artistIDs: [String]
geneIDs: [String]
Expand Down Expand Up @@ -14612,7 +14622,9 @@ union NotificationItem =
| ArticleFeaturedArtistNotificationItem
| ArtworkPublishedNotificationItem
| CollectorProfileUpdatePromptNotificationItem
| MarketingCollectionHitNotificationItem
| PartnerOfferCreatedNotificationItem
| SavedArtworkChangesNotificationItem
| ShowOpenedNotificationItem
| ViewingRoomPublishedNotificationItem

Expand All @@ -14636,8 +14648,10 @@ enum NotificationTypesEnum {
ARTWORK_ALERT
ARTWORK_PUBLISHED
COLLECTOR_PROFILE_UPDATE_PROMPT
MARKETING_COLLECTION_HIT
PARTNER_OFFER_CREATED
PARTNER_SHOW_OPENED
SAVED_ARTWORK_CHANGES
VIEWING_ROOM_PUBLISHED
}

Expand Down Expand Up @@ -18486,6 +18500,16 @@ type SaveArtworkPayload {
me: Me!
}

type SavedArtworkChangesNotificationItem {
artwork: Artwork
artworksConnection(
after: String
before: String
first: Int
last: Int
): ArtworkConnection
}

# A connection to a list of items.
type SavedArtworksConnection {
default: Boolean!
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { GraphQLObjectType } from "graphql"
import { connectionFromArray } from "graphql-relay"
import { convertConnectionArgsToGravityArgs } from "lib/helpers"
import { pageable } from "relay-cursor-paging"
import { artworkConnection } from "schema/v2/artwork"
import { createPageCursors } from "schema/v2/fields/pagination"
import { MarketingCollectionType } from "schema/v2/marketingCollections"
import { ResolverContext } from "types/graphql"

export const MarketingCollectionHitNotificationItemType = new GraphQLObjectType<
any,
ResolverContext
>({
name: "MarketingCollectionHitNotificationItem",
fields: {
marketingCollection: {
type: MarketingCollectionType,
resolve: ({ actor_ids }, _args, { marketingCollectionLoader }) => {
if (!marketingCollectionLoader) {
throw new Error("You need to be signed in to perform this action")
}

if (!actor_ids) return null

const collectionID = actor_ids[0]

return marketingCollectionLoader(collectionID)
},
},

artworksConnection: {
type: artworkConnection.connectionType,
args: pageable(),
resolve: async ({ object_ids }, args, { artworksLoader }) => {
const { page, size } = convertConnectionArgsToGravityArgs(args)
const body = await artworksLoader({ ids: object_ids })
const totalCount = body.length

return {
totalCount,
pageCursors: createPageCursors({ page, size }, totalCount),
...connectionFromArray(body, args),
}
},
},
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { GraphQLObjectType } from "graphql"
import { connectionFromArray } from "graphql-relay"
import { convertConnectionArgsToGravityArgs } from "lib/helpers"
import { pageable } from "relay-cursor-paging"
import { artworkConnection, ArtworkType } from "schema/v2/artwork"
import { createPageCursors } from "schema/v2/fields/pagination"
import { ResolverContext } from "types/graphql"

export const SavedArtworkChangesNotificationItemType = new GraphQLObjectType<
any,
ResolverContext
>({
name: "SavedArtworkChangesNotificationItem",
fields: {
artwork: {
type: ArtworkType,
resolve: ({ actor_ids }, _args, { artworkLoader }) => {
if (!actor_ids) return null

const artworkId = actor_ids[0]

return artworkLoader(artworkId)
},
},

// TODO: maybe we don't need this field
artworksConnection: {
type: artworkConnection.connectionType,
args: pageable(),
resolve: async ({ object_ids }, args, { artworksLoader }) => {
const { page, size } = convertConnectionArgsToGravityArgs(args)
const body = await artworksLoader({ ids: object_ids })
const totalCount = body.length

return {
totalCount,
pageCursors: createPageCursors({ page, size }, totalCount),
...connectionFromArray(body, args),
}
},
},
},
})
8 changes: 8 additions & 0 deletions src/schema/v2/notifications/Item/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { ShowOpenedNotificationItemType } from "./ShowOpenedNotificationItem"
import { ViewingRoomPublishedNotificationItemType } from "./ViewingRoomPublishedNotificationItem"
import { PartnerOfferCreatedNotificationItemType } from "./PartnerOfferCreatedNotificationItem"
import { CollectorProfileUpdatePromptNotificationItemType } from "./CollectorProfileUpdatePromptNotificationItem"
import { MarketingCollectionHitNotificationItemType } from "./MarketingCollectionHitNotificationItem"
import { SavedArtworkChangesNotificationItemType } from "./SavedArtworkChangesNotificationItem"

export const NotificationItemType = new GraphQLUnionType({
name: "NotificationItem",
Expand All @@ -17,6 +19,8 @@ export const NotificationItemType = new GraphQLUnionType({
ViewingRoomPublishedNotificationItemType,
PartnerOfferCreatedNotificationItemType,
CollectorProfileUpdatePromptNotificationItemType,
MarketingCollectionHitNotificationItemType,
SavedArtworkChangesNotificationItemType,
],
resolveType: ({ activity_type }) => {
switch (activity_type) {
Expand All @@ -34,6 +38,10 @@ export const NotificationItemType = new GraphQLUnionType({
return PartnerOfferCreatedNotificationItemType
case "CollectorProfileUpdatePromptActivity":
return CollectorProfileUpdatePromptNotificationItemType
case "MarketingCollectionHitActivity":
return MarketingCollectionHitNotificationItemType
case "SavedArtworkChangesActivity":
return SavedArtworkChangesNotificationItemType
default:
throw new Error("Unknown notification content type")
}
Expand Down
2 changes: 2 additions & 0 deletions src/schema/v2/notifications/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const NotificationTypesEnum = new GraphQLEnumType({
VIEWING_ROOM_PUBLISHED: { value: "ViewingRoomPublishedActivity" },
PARTNER_SHOW_OPENED: { value: "PartnerShowOpenedActivity" },
PARTNER_OFFER_CREATED: { value: "PartnerOfferCreatedActivity" },
MARKETING_COLLECTION_HIT: { value: "MarketingCollectionHitActivity" },
SAVED_ARTWORK_CHANGES: { value: "SavedArtworkChangesActivity" },
},
})

Expand Down