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: add non bnmo purchases to CollectorResume buyerActivity #5621

Merged
merged 4 commits into from Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions _schemaV2.graphql
Expand Up @@ -4246,6 +4246,9 @@ type CollectorResume {
# The Collector follows the Gallery profile
isCollectorFollowingPartner: Boolean!

# non-bnmo Collector's purchase history
purchases: purchases

# Collector's ID used to stitch buyerActivity with the Exchange schema
userId: String!
}
Expand Down Expand Up @@ -15262,6 +15265,14 @@ type PublishViewingRoomPayload {
viewingRoom: ViewingRoom!
}

type purchases {
# Total number of auction winning bids
totalAuctionCount: Int

# Total number of private sales
totalPrivateSaleCount: Int
}

type Query {
# Do not use (only used internally for stitching)
_do_not_use_conversation(
Expand Down
45 changes: 34 additions & 11 deletions src/lib/stitching/exchange/v2/stitching.ts
Expand Up @@ -357,21 +357,44 @@ export const exchangeStitchingEnvironment = ({
fragment: gql`
... on CollectorResume {
userId
purchases {
egdbear marked this conversation as resolved.
Show resolved Hide resolved
totalAuctionCount
totalPrivateSaleCount
}
}
`,
resolve: async (parent, _args, context, info) => {
const exchangeArgs = {
buyerId: parent.userId,
}
const nonBnmoPurchases =
(parent?.purchases?.totalAuctionCount ?? 0) +
(parent?.purchases?.totalPrivateSaleCount ?? 0)

return await info.mergeInfo.delegateToSchema({
schema: exchangeSchema,
operation: "query",
fieldName: "commerceBuyerActivity",
args: exchangeArgs,
context,
info,
})
try {
const exchangeArgs = {
buyerId: parent.userId,
}

const bnmoPurchases = await info.mergeInfo.delegateToSchema({
schema: exchangeSchema,
operation: "query",
fieldName: "commerceBuyerActivity",
args: exchangeArgs,
context,
info,
})

return {
totalPurchases: bnmoPurchases.totalPurchases + nonBnmoPurchases,
iskounen marked this conversation as resolved.
Show resolved Hide resolved
}
} catch (error) {
iskounen marked this conversation as resolved.
Show resolved Hide resolved
console.error(
"[schema/v2/conversation/collectorResume/totalPurchases] Error:",
error
)

return {
totalPurchases: nonBnmoPurchases,
}
}
},
},
},
Expand Down
22 changes: 22 additions & 0 deletions src/schema/v2/conversation/collectorResume.ts
Expand Up @@ -3,6 +3,7 @@ import {
GraphQLString,
GraphQLNonNull,
GraphQLBoolean,
GraphQLInt,
} from "graphql"
import { CollectorProfileType } from "schema/v2/CollectorProfile/collectorProfile"
import { ResolverContext } from "types/graphql"
Expand All @@ -25,5 +26,26 @@ export const CollectorResume = new GraphQLObjectType<any, ResolverContext>({
"Collector's ID used to stitch buyerActivity with the Exchange schema",
resolve: ({ userId }) => userId,
},
purchases: {
type: CollectorPurchasesType,
description: "non-bnmo Collector's purchase history",
resolve: ({ purchases }) => purchases,
},
}),
})

const CollectorPurchasesType = new GraphQLObjectType<any, ResolverContext>({
name: "purchases",
fields: {
totalAuctionCount: {
type: GraphQLInt,
description: "Total number of auction winning bids",
resolve: ({ auction }) => auction,
},
totalPrivateSaleCount: {
type: GraphQLInt,
egdbear marked this conversation as resolved.
Show resolved Hide resolved
description: "Total number of private sales",
resolve: (data) => data["private sale"],
},
},
})
1 change: 1 addition & 0 deletions src/schema/v2/conversation/index.ts
Expand Up @@ -331,6 +331,7 @@ export const ConversationType = new GraphQLObjectType<any, ResolverContext>({
},
isCollectorFollowingPartner: data.follows_profile,
userId: from_id,
purchases: data.purchases,
}
} catch (error) {
console.error(
Expand Down