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(ONYX-1294): add priceListed field to PartnerOfferToCollectorType #6154

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions _schemaV2.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -15796,6 +15796,7 @@ type PartnerOfferToCollector implements Node {
isAvailable: Boolean
note: String
partnerId: String
priceListed: Money
priceWithDiscount: Money
source: PartnerOfferSourceEnum
}
Expand Down
58 changes: 34 additions & 24 deletions src/schema/v2/me/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ describe("me/index", () => {
active: true,
artwork_id: "65d9b98ae37dd70006240bf6",
available: true,
minor: 5600000,
currencyCode: "USD",
note: "This is a note!",
partner_id: "5f80bfefe8d808000ea212c1",
price_currency: "USD",
Expand Down Expand Up @@ -744,6 +746,9 @@ describe("me/index", () => {
isAvailable
note
partnerId
priceListed {
display
}
priceWithDiscount {
display
major
Expand All @@ -769,33 +774,38 @@ describe("me/index", () => {
total_count: true,
})

expect(response).toEqual({
me: {
partnerOffersConnection: {
totalCount: 1,
edges: [
{
node: {
artworkId: "65d9b98ae37dd70006240bf6",
createdAt: "2024-02-27T19:01:51.461Z",
endAt: "2024-03-01T19:01:51.457Z",
internalID: "866f16a0-92bf-4fb6-8911-e1ab1a5fb508",
isActive: true,
isAvailable: true,
note: "This is a note!",
partnerId: "5f80bfefe8d808000ea212c1",
priceWithDiscount: {
currencyCode: "USD",
display: "US$17,360",
minor: 1736000,
major: 17360,
expect(response).toMatchInlineSnapshot(`
Object {
"me": Object {
"partnerOffersConnection": Object {
"edges": Array [
Object {
"node": Object {
"artworkId": "65d9b98ae37dd70006240bf6",
"createdAt": "2024-02-27T19:01:51.461Z",
"endAt": "2024-03-01T19:01:51.457Z",
"internalID": "866f16a0-92bf-4fb6-8911-e1ab1a5fb508",
"isActive": true,
"isAvailable": true,
"note": "This is a note!",
"partnerId": "5f80bfefe8d808000ea212c1",
"priceListed": Object {
"display": "US$56,000",
},
"priceWithDiscount": Object {
"currencyCode": "USD",
"display": "US$17,360",
"major": 17360,
"minor": 1736000,
},
},
},
},
],
],
"totalCount": 1,
},
},
},
})
}
`)
})

it("returns partner offers for the collector on an artwork", async () => {
Expand Down
29 changes: 24 additions & 5 deletions src/schema/v2/partnerOfferToCollector.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { date } from "./fields/date"
import {
GraphQLObjectType,
GraphQLString,
GraphQLBoolean,
GraphQLEnumType,
GraphQLObjectType,
GraphQLString,
} from "graphql"
import { ResolverContext } from "types/graphql"
import { IDFields, NodeInterface } from "./object_identification"
import { connectionWithCursorInfo } from "./fields/pagination"
import { date } from "./fields/date"
import { Money, resolveMinorAndCurrencyFieldsToMoney } from "./fields/money"
import { connectionWithCursorInfo } from "./fields/pagination"
import { IDFields, NodeInterface } from "./object_identification"
import { PartnerOfferSourceEnumType } from "./partnerOffer"

export const PartnerOfferToCollectorType = new GraphQLObjectType<
Expand Down Expand Up @@ -40,6 +40,25 @@ export const PartnerOfferToCollectorType = new GraphQLObjectType<
type: GraphQLString,
resolve: ({ partner_id }) => partner_id,
},
priceListed: {
type: Money,
resolve: (
{ price_listed_minor: minor, price_currency: currencyCode },
args,
context,
info
) => {
return resolveMinorAndCurrencyFieldsToMoney(
{
minor,
currencyCode,
},
args,
context,
info
)
},
},
priceWithDiscount: {
type: Money,
resolve: (
Expand Down