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 "detailUrl" resolver to order form Item #193

Draft
wants to merge 3 commits 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add `DetailUrl` resolver to `Item` type

## [0.67.0] - 2024-02-27

### Added
Expand Down
1 change: 1 addition & 0 deletions graphql/types/Item.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Item {
bundleItems: [Item!]!
detailUrl: String
id: ID!
linkText: String
imageUrls: ImageUrls
listPrice: Float
manualPrice: Float
Expand Down
2 changes: 2 additions & 0 deletions node/clients/searchGraphQL/productQuery.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface ProductResponse {
productName: string
productId: string
linkText: String
items: Array<{
itemId: string
name: string
Expand Down Expand Up @@ -33,6 +34,7 @@ query Product($values: [ID!]!) {
productsByIdentifier(field: id, values: $values) {
productName
productId
linkText
items {
itemId
name
Expand Down
2 changes: 1 addition & 1 deletion node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@types/node": "^12.0.0",
"@types/ramda": "types/npm-ramda#dist",
"@types/set-cookie-parser": "^2.4.2",
"@vtex/api": "6.45.20",
"@vtex/api": "6.46.1",
"@vtex/test-tools": "^3.1.0",
"@vtex/tsconfig": "^0.2.0",
"typescript": "3.9.7",
Expand Down
10 changes: 10 additions & 0 deletions node/resolvers/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ export const root = {

return product?.productName ?? item.name
},
detailUrl: async (item: OrderFormItem, _: unknown, ctx: Context) => {
const {
vtex: { logger },
clients: { searchGraphQL },
} = ctx

const product = await getProductInfo(item, searchGraphQL, logger)

return product?.linkText.concat('/p') ?? []
},
skuName: async (item: OrderFormItem, _: unknown, ctx: Context) => {
const {
vtex: { logger },
Expand Down
8 changes: 4 additions & 4 deletions node/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1604,10 +1604,10 @@
resolved "https://registry.yarnpkg.com/@types/zen-observable/-/zen-observable-0.8.0.tgz#8b63ab7f1aa5321248aad5ac890a485656dcea4d"
integrity sha512-te5lMAWii1uEJ4FwLjzdlbw3+n0FZNOvFXHxQDKeT0dilh7HOzdMzV2TrJVUzq8ep7J4Na8OUYPRLSQkJHAlrg==

"@vtex/api@6.45.20":
version "6.45.20"
resolved "https://registry.yarnpkg.com/@vtex/api/-/api-6.45.20.tgz#c1090249a424fd700499de3fed0d80d99ff53332"
integrity sha512-O7RJWWr4PfvixNpc0GgQh85iKcv9j1IKkpApwJQSW/WzxoTgSrcjYHOVUmJ1GWWBmRV/qvB2VaV6Ow1QL3UOCQ==
"@vtex/api@6.46.1":
version "6.46.1"
resolved "https://registry.yarnpkg.com/@vtex/api/-/api-6.46.1.tgz#55a8755ae48f5400e7f1ed1921cd547950bb7a2a"
integrity sha512-geoxVvyWoQpOQ70Zmx3M8SBkRoGOS/bp9Gy26M+iCue63jofVSwmFz1zf66EaHA1PKOJNRgQPFwY+oeDE1U2lQ==
dependencies:
"@types/koa" "^2.11.0"
"@types/koa-compose" "^3.2.3"
Expand Down