Skip to content

Commit 59c6df5

Browse files
authored
StackAdapt Audience: update GQL query formatting (#3175)
* update gql query formatting * lint
1 parent 03f956b commit 59c6df5

File tree

7 files changed

+137
-66
lines changed

7 files changed

+137
-66
lines changed

packages/destination-actions/src/destinations/stackadapt-audiences/__tests__/__snapshots__/snapshot.test.ts.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ Object {
1818
upsertProfileMapping(
1919
input: {
2020
advertiserId: 84GW[vK%wv2xv@UF5iy,
21-
mappingSchemaV2: [{\\\\\\"incomingKey\\\\\\":\\\\\\"userId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"isPii\\\\\\":false,\\\\\\"label\\\\\\":\\\\\\"External Profile ID\\\\\\"}],
22-
mappableType: \\"segment_io\\",
21+
mappingSchemaV2: [{incomingKey:\\"userId\\",destinationKey:\\"external_id\\",type:STRING,isPii:false,label:\\"External Profile ID\\"}],
22+
mappableType: \\"segment_io\\"
2323
}
2424
) {
2525
userErrors {
@@ -29,7 +29,7 @@ Object {
2929
upsertExternalAudienceMapping(
3030
input: {
3131
advertiserId: 84GW[vK%wv2xv@UF5iy,
32-
mappingSchema: [{\\\\\\"incomingKey\\\\\\":\\\\\\"audienceId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"label\\\\\\":\\\\\\"External Audience ID\\\\\\",\\\\\\"isPii\\\\\\":false},{\\\\\\"incomingKey\\\\\\":\\\\\\"audienceName\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"name\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"label\\\\\\":\\\\\\"External Audience Name\\\\\\",\\\\\\"isPii\\\\\\":false}],
32+
mappingSchema: [{incomingKey:\\"audienceId\\",destinationKey:\\"external_id\\",type:STRING,label:\\"External Audience ID\\",isPii:false},{incomingKey:\\"audienceName\\",destinationKey:\\"name\\",type:STRING,label:\\"External Audience Name\\",isPii:false}],
3333
mappableType: \\"segment_io\\"
3434
}
3535
) {
@@ -59,8 +59,8 @@ Object {
5959
upsertProfileMapping(
6060
input: {
6161
advertiserId: 84GW[vK%wv2xv@UF5iy,
62-
mappingSchemaV2: [{\\\\\\"incomingKey\\\\\\":\\\\\\"userId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"isPii\\\\\\":false,\\\\\\"label\\\\\\":\\\\\\"External Profile ID\\\\\\"}],
63-
mappableType: \\"segment_io\\",
62+
mappingSchemaV2: [{incomingKey:\\"userId\\",destinationKey:\\"external_id\\",type:STRING,isPii:false,label:\\"External Profile ID\\"}],
63+
mappableType: \\"segment_io\\"
6464
}
6565
) {
6666
userErrors {
@@ -70,7 +70,7 @@ Object {
7070
upsertExternalAudienceMapping(
7171
input: {
7272
advertiserId: 84GW[vK%wv2xv@UF5iy,
73-
mappingSchema: [{\\\\\\"incomingKey\\\\\\":\\\\\\"audienceId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"label\\\\\\":\\\\\\"External Audience ID\\\\\\",\\\\\\"isPii\\\\\\":false},{\\\\\\"incomingKey\\\\\\":\\\\\\"audienceName\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"name\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"label\\\\\\":\\\\\\"External Audience Name\\\\\\",\\\\\\"isPii\\\\\\":false}],
73+
mappingSchema: [{incomingKey:\\"audienceId\\",destinationKey:\\"external_id\\",type:STRING,label:\\"External Audience ID\\",isPii:false},{incomingKey:\\"audienceName\\",destinationKey:\\"name\\",type:STRING,label:\\"External Audience Name\\",isPii:false}],
7474
mappableType: \\"segment_io\\"
7575
}
7676
) {
@@ -100,8 +100,8 @@ Object {
100100
upsertProfileMapping(
101101
input: {
102102
advertiserId: PsAwlRv%,
103-
mappingSchemaV2: [{\\\\\\"incomingKey\\\\\\":\\\\\\"userId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"label\\\\\\":\\\\\\"User Id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"isPii\\\\\\":false}],
104-
mappableType: \\"segment_io\\",
103+
mappingSchemaV2: [{incomingKey:\\"userId\\",destinationKey:\\"external_id\\",label:\\"User Id\\",type:STRING,isPii:false}],
104+
mappableType: \\"segment_io\\"
105105
}
106106
) {
107107
userErrors {
@@ -130,8 +130,8 @@ Object {
130130
upsertProfileMapping(
131131
input: {
132132
advertiserId: PsAwlRv%,
133-
mappingSchemaV2: [{\\\\\\"incomingKey\\\\\\":\\\\\\"userId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"label\\\\\\":\\\\\\"User Id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"isPii\\\\\\":false}],
134-
mappableType: \\"segment_io\\",
133+
mappingSchemaV2: [{incomingKey:\\"userId\\",destinationKey:\\"external_id\\",label:\\"User Id\\",type:STRING,isPii:false}],
134+
mappableType: \\"segment_io\\"
135135
}
136136
) {
137137
userErrors {

packages/destination-actions/src/destinations/stackadapt-audiences/__tests__/functions.test.ts

Lines changed: 88 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { stringifyJsonWithEscapedQuotes } from '../functions'
1+
import { stringifyJsonWithEscapedQuotes, stringifyMappingSchemaForGraphQL } from '../functions'
22

33
describe('stringifyJsonWithEscapedQuotes', () => {
44
it('should escape quotes in a simple object', () => {
@@ -38,35 +38,96 @@ describe('stringifyJsonWithEscapedQuotes', () => {
3838
expect(stringifyJsonWithEscapedQuotes(null)).toBe('null')
3939
})
4040

41-
describe('type field transformation', () => {
42-
it('should transform type field to uppercase without quotes', () => {
43-
const input = { type: 'string' }
44-
const expected = '{\\"type\\":STRING}'
45-
expect(stringifyJsonWithEscapedQuotes(input)).toBe(expected)
46-
})
41+
})
4742

48-
it('should transform type field when it\'s already uppercase', () => {
49-
const input = { type: 'STRING' }
50-
const expected = '{\\"type\\":STRING}'
51-
expect(stringifyJsonWithEscapedQuotes(input)).toBe(expected)
52-
})
43+
describe('stringifyMappingSchemaForGraphQL', () => {
44+
it('should transform simple mapping object for GraphQL', () => {
45+
const input = {
46+
incomingKey: 'userId',
47+
destinationKey: 'external_id',
48+
label: 'User Id',
49+
type: 'STRING',
50+
isPii: false
51+
}
52+
const expected = '{incomingKey:"userId",destinationKey:"external_id",label:"User Id",type:STRING,isPii:false}'
53+
expect(stringifyMappingSchemaForGraphQL(input)).toBe(expected)
54+
})
55+
56+
it('should transform type field to uppercase and unquoted', () => {
57+
const input = { type: 'string' }
58+
const expected = '{type:STRING}'
59+
expect(stringifyMappingSchemaForGraphQL(input)).toBe(expected)
60+
})
5361

54-
it('should transform type field in nested objects', () => {
55-
const input = { data: { type: 'string' } }
56-
const expected = '{\\"data\\":{\\"type\\":STRING}}'
57-
expect(stringifyJsonWithEscapedQuotes(input)).toBe(expected)
58-
})
62+
it('should transform type field when it\'s already uppercase', () => {
63+
const input = { type: 'STRING' }
64+
const expected = '{type:STRING}'
65+
expect(stringifyMappingSchemaForGraphQL(input)).toBe(expected)
66+
})
5967

60-
it('should transform type fields in an array of objects', () => {
61-
const input = {
62-
mappings: [
63-
{ type: 'string', field: 'name' },
64-
{ type: 'number', field: 'age' },
65-
{ type: 'boolean', field: 'active' }
66-
]
68+
it('should handle array of mapping objects', () => {
69+
const input = [
70+
{
71+
incomingKey: 'userId',
72+
destinationKey: 'external_id',
73+
type: 'STRING',
74+
isPii: false,
75+
label: 'External Profile ID'
76+
},
77+
{
78+
incomingKey: 'email',
79+
destinationKey: 'email',
80+
type: 'string',
81+
isPii: true,
82+
label: 'Email Address'
6783
}
68-
const expected = '{\\"mappings\\":[{\\"type\\":STRING,\\"field\\":\\"name\\"},{\\"type\\":NUMBER,\\"field\\":\\"age\\"},{\\"type\\":BOOLEAN,\\"field\\":\\"active\\"}]}'
69-
expect(stringifyJsonWithEscapedQuotes(input)).toBe(expected)
70-
})
84+
]
85+
const expected = '[{incomingKey:"userId",destinationKey:"external_id",type:STRING,isPii:false,label:"External Profile ID"},{incomingKey:"email",destinationKey:"email",type:STRING,isPii:true,label:"Email Address"}]'
86+
expect(stringifyMappingSchemaForGraphQL(input)).toBe(expected)
87+
})
88+
89+
it('should handle different type values', () => {
90+
const input = {
91+
mappings: [
92+
{ type: 'string', field: 'name' },
93+
{ type: 'number', field: 'age' },
94+
{ type: 'boolean', field: 'active' }
95+
]
96+
}
97+
const expected = '{mappings:[{type:STRING,field:"name"},{type:NUMBER,field:"age"},{type:BOOLEAN,field:"active"}]}'
98+
expect(stringifyMappingSchemaForGraphQL(input)).toBe(expected)
99+
})
100+
101+
it('should unquote all object keys for GraphQL syntax', () => {
102+
const input = {
103+
incomingKey: 'test',
104+
destinationKey: 'test_field',
105+
customProperty: 'value',
106+
type: 'string'
107+
}
108+
const expected = '{incomingKey:"test",destinationKey:"test_field",customProperty:"value",type:STRING}'
109+
expect(stringifyMappingSchemaForGraphQL(input)).toBe(expected)
110+
})
111+
112+
it('should preserve string values with quotes', () => {
113+
const input = {
114+
label: 'User Name with "quotes"',
115+
description: 'Field description',
116+
type: 'string'
117+
}
118+
const expected = '{label:"User Name with \\"quotes\\"",description:"Field description",type:STRING}'
119+
expect(stringifyMappingSchemaForGraphQL(input)).toBe(expected)
120+
})
121+
122+
it('should handle nested objects', () => {
123+
const input = {
124+
field: {
125+
incomingKey: 'nested',
126+
type: 'string'
127+
},
128+
type: 'object'
129+
}
130+
const expected = '{field:{incomingKey:"nested",type:STRING},type:OBJECT}'
131+
expect(stringifyMappingSchemaForGraphQL(input)).toBe(expected)
71132
})
72133
})

packages/destination-actions/src/destinations/stackadapt-audiences/forwardAudienceEvent/__tests__/index.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ describe('forwardAudienceEvent', () => {
9595
upsertProfileMapping(
9696
input: {
9797
advertiserId: 23,
98-
mappingSchemaV2: [{\\\\\\"incomingKey\\\\\\":\\\\\\"userId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"isPii\\\\\\":false,\\\\\\"label\\\\\\":\\\\\\"External Profile ID\\\\\\"}],
99-
mappableType: \\"segment_io\\",
98+
mappingSchemaV2: [{incomingKey:\\"userId\\",destinationKey:\\"external_id\\",type:STRING,isPii:false,label:\\"External Profile ID\\"}],
99+
mappableType: \\"segment_io\\"
100100
}
101101
) {
102102
userErrors {
@@ -106,7 +106,7 @@ describe('forwardAudienceEvent', () => {
106106
upsertExternalAudienceMapping(
107107
input: {
108108
advertiserId: 23,
109-
mappingSchema: [{\\\\\\"incomingKey\\\\\\":\\\\\\"audienceId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"label\\\\\\":\\\\\\"External Audience ID\\\\\\",\\\\\\"isPii\\\\\\":false},{\\\\\\"incomingKey\\\\\\":\\\\\\"audienceName\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"name\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"label\\\\\\":\\\\\\"External Audience Name\\\\\\",\\\\\\"isPii\\\\\\":false}],
109+
mappingSchema: [{incomingKey:\\"audienceId\\",destinationKey:\\"external_id\\",type:STRING,label:\\"External Audience ID\\",isPii:false},{incomingKey:\\"audienceName\\",destinationKey:\\"name\\",type:STRING,label:\\"External Audience Name\\",isPii:false}],
110110
mappableType: \\"segment_io\\"
111111
}
112112
) {
@@ -169,8 +169,8 @@ describe('forwardAudienceEvent', () => {
169169
upsertProfileMapping(
170170
input: {
171171
advertiserId: 23,
172-
mappingSchemaV2: [{\\\\\\"incomingKey\\\\\\":\\\\\\"userId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"isPii\\\\\\":false,\\\\\\"label\\\\\\":\\\\\\"External Profile ID\\\\\\"}],
173-
mappableType: \\"segment_io\\",
172+
mappingSchemaV2: [{incomingKey:\\"userId\\",destinationKey:\\"external_id\\",type:STRING,isPii:false,label:\\"External Profile ID\\"}],
173+
mappableType: \\"segment_io\\"
174174
}
175175
) {
176176
userErrors {
@@ -180,7 +180,7 @@ describe('forwardAudienceEvent', () => {
180180
upsertExternalAudienceMapping(
181181
input: {
182182
advertiserId: 23,
183-
mappingSchema: [{\\\\\\"incomingKey\\\\\\":\\\\\\"audienceId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"label\\\\\\":\\\\\\"External Audience ID\\\\\\",\\\\\\"isPii\\\\\\":false},{\\\\\\"incomingKey\\\\\\":\\\\\\"audienceName\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"name\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"label\\\\\\":\\\\\\"External Audience Name\\\\\\",\\\\\\"isPii\\\\\\":false}],
183+
mappingSchema: [{incomingKey:\\"audienceId\\",destinationKey:\\"external_id\\",type:STRING,label:\\"External Audience ID\\",isPii:false},{incomingKey:\\"audienceName\\",destinationKey:\\"name\\",type:STRING,label:\\"External Audience Name\\",isPii:false}],
184184
mappableType: \\"segment_io\\"
185185
}
186186
) {
@@ -228,8 +228,8 @@ describe('forwardAudienceEvent', () => {
228228
upsertProfileMapping(
229229
input: {
230230
advertiserId: 23,
231-
mappingSchemaV2: [{\\\\\\"incomingKey\\\\\\":\\\\\\"userId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"isPii\\\\\\":false,\\\\\\"label\\\\\\":\\\\\\"External Profile ID\\\\\\"}],
232-
mappableType: \\"segment_io\\",
231+
mappingSchemaV2: [{incomingKey:\\"userId\\",destinationKey:\\"external_id\\",type:STRING,isPii:false,label:\\"External Profile ID\\"}],
232+
mappableType: \\"segment_io\\"
233233
}
234234
) {
235235
userErrors {
@@ -239,7 +239,7 @@ describe('forwardAudienceEvent', () => {
239239
upsertExternalAudienceMapping(
240240
input: {
241241
advertiserId: 23,
242-
mappingSchema: [{\\\\\\"incomingKey\\\\\\":\\\\\\"audienceId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"label\\\\\\":\\\\\\"External Audience ID\\\\\\",\\\\\\"isPii\\\\\\":false},{\\\\\\"incomingKey\\\\\\":\\\\\\"audienceName\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"name\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"label\\\\\\":\\\\\\"External Audience Name\\\\\\",\\\\\\"isPii\\\\\\":false}],
242+
mappingSchema: [{incomingKey:\\"audienceId\\",destinationKey:\\"external_id\\",type:STRING,label:\\"External Audience ID\\",isPii:false},{incomingKey:\\"audienceName\\",destinationKey:\\"name\\",type:STRING,label:\\"External Audience Name\\",isPii:false}],
243243
mappableType: \\"segment_io\\"
244244
}
245245
) {

packages/destination-actions/src/destinations/stackadapt-audiences/forwardAudienceEvent/functions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { RequestClient } from '@segment/actions-core'
22
import { Payload } from './generated-types'
3-
import { GQL_ENDPOINT, EXTERNAL_PROVIDER, sha256hash, stringifyJsonWithEscapedQuotes } from '../functions'
3+
import { GQL_ENDPOINT, EXTERNAL_PROVIDER, sha256hash, stringifyJsonWithEscapedQuotes, stringifyMappingSchemaForGraphQL } from '../functions'
44

5-
const audienceMapping = stringifyJsonWithEscapedQuotes([
5+
const audienceMapping = stringifyMappingSchemaForGraphQL([
66
{
77
incomingKey: 'audienceId',
88
destinationKey: 'external_id',
@@ -20,7 +20,7 @@ const audienceMapping = stringifyJsonWithEscapedQuotes([
2020
}
2121
])
2222

23-
const profileMapping = stringifyJsonWithEscapedQuotes([
23+
const profileMapping = stringifyMappingSchemaForGraphQL([
2424
{
2525
incomingKey: 'userId',
2626
destinationKey: 'external_id',
@@ -62,7 +62,7 @@ export async function performForwardAudienceEvents(request: RequestClient, event
6262
input: {
6363
advertiserId: ${advertiserId},
6464
mappingSchemaV2: ${profileMapping},
65-
mappableType: "${EXTERNAL_PROVIDER}",
65+
mappableType: "${EXTERNAL_PROVIDER}"
6666
}
6767
) {
6868
userErrors {

packages/destination-actions/src/destinations/stackadapt-audiences/forwardProfile/__tests__/index.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ describe('forwardProfile', () => {
131131
upsertProfileMapping(
132132
input: {
133133
advertiserId: 23,
134-
mappingSchemaV2: [{\\\\\\"incomingKey\\\\\\":\\\\\\"userId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"label\\\\\\":\\\\\\"User Id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"isPii\\\\\\":false}],
135-
mappableType: \\"segment_io\\",
134+
mappingSchemaV2: [{incomingKey:\\"userId\\",destinationKey:\\"external_id\\",label:\\"User Id\\",type:STRING,isPii:false}],
135+
mappableType: \\"segment_io\\"
136136
}
137137
) {
138138
userErrors {
@@ -194,8 +194,8 @@ describe('forwardProfile', () => {
194194
upsertProfileMapping(
195195
input: {
196196
advertiserId: 23,
197-
mappingSchemaV2: [{\\\\\\"incomingKey\\\\\\":\\\\\\"userId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"label\\\\\\":\\\\\\"User Id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"isPii\\\\\\":false}],
198-
mappableType: \\"segment_io\\",
197+
mappingSchemaV2: [{incomingKey:\\"userId\\",destinationKey:\\"external_id\\",label:\\"User Id\\",type:STRING,isPii:false}],
198+
mappableType: \\"segment_io\\"
199199
}
200200
) {
201201
userErrors {
@@ -242,8 +242,8 @@ describe('forwardProfile', () => {
242242
upsertProfileMapping(
243243
input: {
244244
advertiserId: 23,
245-
mappingSchemaV2: [{\\\\\\"incomingKey\\\\\\":\\\\\\"userId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"label\\\\\\":\\\\\\"User Id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"isPii\\\\\\":false},{\\\\\\"incomingKey\\\\\\":\\\\\\"customField\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"customField\\\\\\",\\\\\\"label\\\\\\":\\\\\\"Custom Field\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"isPii\\\\\\":false},{\\\\\\"incomingKey\\\\\\":\\\\\\"numberCustomField\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"numberCustomField\\\\\\",\\\\\\"label\\\\\\":\\\\\\"Number Custom Field\\\\\\",\\\\\\"type\\\\\\":NUMBER,\\\\\\"isPii\\\\\\":false}],
246-
mappableType: \\"segment_io\\",
245+
mappingSchemaV2: [{incomingKey:\\"userId\\",destinationKey:\\"external_id\\",label:\\"User Id\\",type:STRING,isPii:false},{incomingKey:\\"customField\\",destinationKey:\\"customField\\",label:\\"Custom Field\\",type:STRING,isPii:false},{incomingKey:\\"numberCustomField\\",destinationKey:\\"numberCustomField\\",label:\\"Number Custom Field\\",type:NUMBER,isPii:false}],
246+
mappableType: \\"segment_io\\"
247247
}
248248
) {
249249
userErrors {
@@ -290,8 +290,8 @@ describe('forwardProfile', () => {
290290
upsertProfileMapping(
291291
input: {
292292
advertiserId: 23,
293-
mappingSchemaV2: [{\\\\\\"incomingKey\\\\\\":\\\\\\"userId\\\\\\",\\\\\\"destinationKey\\\\\\":\\\\\\"external_id\\\\\\",\\\\\\"label\\\\\\":\\\\\\"User Id\\\\\\",\\\\\\"type\\\\\\":STRING,\\\\\\"isPii\\\\\\":false}],
294-
mappableType: \\"segment_io\\",
293+
mappingSchemaV2: [{incomingKey:\\"userId\\",destinationKey:\\"external_id\\",label:\\"User Id\\",type:STRING,isPii:false}],
294+
mappableType: \\"segment_io\\"
295295
}
296296
) {
297297
userErrors {

packages/destination-actions/src/destinations/stackadapt-audiences/forwardProfile/functions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { RequestClient } from '@segment/actions-core'
22
import camelCase from 'lodash/camelCase'
33
import isEmpty from 'lodash/isEmpty'
44
import { Payload } from './generated-types'
5-
import { GQL_ENDPOINT, EXTERNAL_PROVIDER, sha256hash, stringifyJsonWithEscapedQuotes } from '../functions'
5+
import { GQL_ENDPOINT, EXTERNAL_PROVIDER, sha256hash, stringifyJsonWithEscapedQuotes, stringifyMappingSchemaForGraphQL } from '../functions'
66

77
const standardFields = new Set([
88
'email',
@@ -74,7 +74,7 @@ export async function performForwardProfiles(request: RequestClient, events: Pay
7474
input: {
7575
advertiserId: ${advertiserId},
7676
mappingSchemaV2: ${getProfileMappings(Array.from(fieldsToMap), fieldTypes)},
77-
mappableType: "${EXTERNAL_PROVIDER}",
77+
mappableType: "${EXTERNAL_PROVIDER}"
7878
}
7979
) {
8080
userErrors {
@@ -119,7 +119,7 @@ function getProfileMappings(customFields: string[], fieldTypes: Record<string, s
119119
isPii: false
120120
})
121121
}
122-
return stringifyJsonWithEscapedQuotes(mappingSchema)
122+
return stringifyMappingSchemaForGraphQL(mappingSchema)
123123
}
124124

125125
function generateLabel(field: string) {

0 commit comments

Comments
 (0)