Skip to content

Commit

Permalink
Merge pull request #113 from vtex-apps/feature/marketing-data-mutation
Browse files Browse the repository at this point in the history
Add mutation updateOrderFormMarketingData
  • Loading branch information
lucasecdb authored Dec 22, 2020
2 parents abfd64f + fe66407 commit 63c6726
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Mutation `updateOrderFormMarketingData`.

## [0.52.1] - 2020-12-14
### Changed
Expand Down
3 changes: 3 additions & 0 deletions graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ type Mutation {
@withOrderFormId
@cacheControl(scope: PRIVATE)

updateOrderFormMarketingData(input: MarketingDataInput!): OrderForm!
@withOrderFormId
@cacheControl(scope: PRIVATE)
}
11 changes: 7 additions & 4 deletions graphql/types/OrderForm.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type OrderForm {
userType: UserType
shipping: Shipping!
marketingData: MarketingData!
totalizers: [Totalizer]!
totalizers: [Totalizer!]!
value: Float!
messages: OrderFormMessages!
paymentData: PaymentData!
Expand All @@ -34,6 +34,7 @@ type MarketingData {
utmiPart: String
utmiPage: String
coupon: String
marketingTags: [String!]!
}

input MarketingDataInput {
Expand All @@ -43,6 +44,8 @@ input MarketingDataInput {
utmiCampaign: String
utmiPart: String
utmiPage: String
coupon: String
marketingTags: [String!]!
}

type Totalizer {
Expand All @@ -52,8 +55,8 @@ type Totalizer {
}

type OrderFormMessages {
couponMessages: [Message]!
generalMessages: [Message]!
couponMessages: [Message!]!
generalMessages: [Message!]!
}

type Message {
Expand All @@ -79,4 +82,4 @@ enum ItemsOrdinationCriteria {

input OrderFormOpenTextInput {
value: String
}
}
35 changes: 33 additions & 2 deletions node/resolvers/orderForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ export const queries = {
args: OrderFormIdArgs,
ctx: Context
): Promise<CheckoutOrderForm> => {
const { clients, vtex, graphql: { cacheControl } } = ctx
const {
clients,
vtex,
graphql: { cacheControl },
} = ctx
const { orderFormId = vtex.orderFormId } = args

cacheControl.noCache = true
Expand Down Expand Up @@ -208,6 +212,10 @@ interface MutationUpdateOrderFormOpenTextField {
input: OpenTextField
}

interface MutationUpdateOrderFormMarketingData {
input: OrderFormMarketingData
}

export const mutations = {
updateOrderFormProfile: async (
_: unknown,
Expand Down Expand Up @@ -307,7 +315,10 @@ export const mutations = {
args: MutationUpdateOrderFormOpenTextField & OrderFormIdArgs,
ctx: Context
): Promise<CheckoutOrderForm> => {
const { clients: { checkout }, vtex } = ctx
const {
clients: { checkout },
vtex,
} = ctx
const { orderFormId = vtex.orderFormId, input } = args

const orderFormWithOpenTextField = await checkout.updateOrderFromOpenTextField(
Expand All @@ -317,4 +328,24 @@ export const mutations = {

return orderFormWithOpenTextField
},

updateOrderFormMarketingData: async (
_: unknown,
args: MutationUpdateOrderFormMarketingData & OrderFormIdArgs,
ctx: Context
): Promise<CheckoutOrderForm> => {
const {
clients: { checkout },
vtex,
} = ctx

const { orderFormId = vtex.orderFormId, input } = args

const updatedOrderForm = await checkout.updateOrderFormMarketingData(
orderFormId!,
input
)

return updatedOrderForm
},
}

0 comments on commit 63c6726

Please sign in to comment.