Skip to content

Commit 2b0223d

Browse files
authored
Adding ID in query (canada-ca#1219)
* load chart summary refactor * domain loaders refactor * email loaders refactored * org loaders refactored * user loaders refactored * user-aff loaders refactored * web scan loaders refactored * update remaining tests to include the merge with id
1 parent 488767f commit 2b0223d

46 files changed

Lines changed: 149 additions & 163 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api-js/src/auth/__tests__/user-required.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('given a userLoaderByKey dataloader', () => {
4646
const expectedCursor = await query`
4747
FOR user IN users
4848
FILTER user.userName == "test.account@istio.actually.exists"
49-
RETURN user
49+
RETURN MERGE({ id: user._key }, user)
5050
`
5151
const expectedUser = await expectedCursor.next()
5252

api-js/src/loaders/chart-summaries/__tests__/load-chart-summary-by-key.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('given the chartSummaryLoaderByKey function', () => {
5858
const expectedCursor = await query`
5959
FOR summary IN chartSummaries
6060
FILTER summary._key == "web"
61-
RETURN summary
61+
RETURN MERGE({ id: summary._key }, summary)
6262
`
6363
const expectedSummary = await expectedCursor.next()
6464

@@ -74,7 +74,7 @@ describe('given the chartSummaryLoaderByKey function', () => {
7474
const expectedSummaries = []
7575
const expectedCursor = await query`
7676
FOR summary IN chartSummaries
77-
RETURN summary
77+
RETURN MERGE({ id: summary._key }, summary)
7878
`
7979

8080
while (expectedCursor.hasNext()) {

api-js/src/loaders/chart-summaries/load-chart-summary-by-key.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports.chartSummaryLoaderByKey = (query, userId, i18n) =>
99
cursor = await query`
1010
FOR summary IN chartSummaries
1111
FILTER summary._key IN ${keys}
12-
RETURN summary
12+
RETURN MERGE({ id: summary._key }, summary)
1313
`
1414
} catch (err) {
1515
console.error(

api-js/src/loaders/domains/__tests__/load-domain-by-domain.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('given a domainLoaderByDomain dataloader', () => {
4242
const expectedCursor = await query`
4343
FOR domain IN domains
4444
FILTER domain.domain == "test.canada.ca"
45-
RETURN domain
45+
RETURN MERGE({ id: domain._key}, domain)
4646
`
4747
const expectedDomain = await expectedCursor.next()
4848

@@ -58,7 +58,7 @@ describe('given a domainLoaderByDomain dataloader', () => {
5858
const expectedDomains = []
5959
const expectedCursor = await query`
6060
FOR domain IN domains
61-
RETURN domain
61+
RETURN MERGE({ id: domain._key}, domain)
6262
`
6363

6464
while (expectedCursor.hasNext()) {
@@ -89,7 +89,7 @@ describe('given a domainLoaderByDomain dataloader', () => {
8989
const expectedCursor = await query`
9090
FOR domain IN domains
9191
FILTER domain.domain == "test.canada.ca"
92-
RETURN domain
92+
RETURN MERGE({ id: domain._key}, domain)
9393
`
9494
const expectedDomain = await expectedCursor.next()
9595

@@ -116,7 +116,7 @@ describe('given a domainLoaderByDomain dataloader', () => {
116116
const expectedCursor = await query`
117117
FOR domain IN domains
118118
FILTER domain.domain == "test.canada.ca"
119-
RETURN domain
119+
RETURN MERGE({ id: domain._key}, domain)
120120
`
121121
const expectedDomain = await expectedCursor.next()
122122

@@ -159,7 +159,7 @@ describe('given a domainLoaderByDomain dataloader', () => {
159159
const expectedCursor = await query`
160160
FOR domain IN domains
161161
FILTER domain.domain == "test.canada.ca"
162-
RETURN domain
162+
RETURN MERGE({ id: domain._key}, domain)
163163
`
164164
const expectedDomain = await expectedCursor.next()
165165

@@ -184,7 +184,7 @@ describe('given a domainLoaderByDomain dataloader', () => {
184184
const expectedCursor = await query`
185185
FOR domain IN domains
186186
FILTER domain.domain == "test.canada.ca"
187-
RETURN domain
187+
RETURN MERGE({ id: domain._key}, domain)
188188
`
189189
const expectedDomain = await expectedCursor.next()
190190

api-js/src/loaders/domains/__tests__/load-domain-by-key.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('given a domainLoaderByKey dataloader', () => {
4444
const expectedCursor = await query`
4545
FOR domain IN domains
4646
FILTER domain.domain == "test.canada.ca"
47-
RETURN domain
47+
RETURN MERGE({ id: domain._key}, domain)
4848
`
4949
const expectedDomain = await expectedCursor.next()
5050

@@ -60,7 +60,7 @@ describe('given a domainLoaderByKey dataloader', () => {
6060
const expectedDomains = []
6161
const expectedCursor = await query`
6262
FOR domain IN domains
63-
RETURN domain
63+
RETURN MERGE({ id: domain._key}, domain)
6464
`
6565

6666
while (expectedCursor.hasNext()) {
@@ -91,7 +91,7 @@ describe('given a domainLoaderByKey dataloader', () => {
9191
const expectedCursor = await query`
9292
FOR domain IN domains
9393
FILTER domain.domain == "test.canada.ca"
94-
RETURN domain
94+
RETURN MERGE({ id: domain._key}, domain)
9595
`
9696
const expectedDomain = await expectedCursor.next()
9797

@@ -118,7 +118,7 @@ describe('given a domainLoaderByKey dataloader', () => {
118118
const expectedCursor = await query`
119119
FOR domain IN domains
120120
FILTER domain.domain == "test.canada.ca"
121-
RETURN domain
121+
RETURN MERGE({ id: domain._key}, domain)
122122
`
123123
const expectedDomain = await expectedCursor.next()
124124

@@ -161,7 +161,7 @@ describe('given a domainLoaderByKey dataloader', () => {
161161
const expectedCursor = await query`
162162
FOR domain IN domains
163163
FILTER domain.domain == "test.canada.ca"
164-
RETURN domain
164+
RETURN MERGE({ id: domain._key}, domain)
165165
`
166166
const expectedDomain = await expectedCursor.next()
167167

@@ -186,7 +186,7 @@ describe('given a domainLoaderByKey dataloader', () => {
186186
const expectedCursor = await query`
187187
FOR domain IN domains
188188
FILTER domain.domain == "test.canada.ca"
189-
RETURN domain
189+
RETURN MERGE({ id: domain._key}, domain)
190190
`
191191
const expectedDomain = await expectedCursor.next()
192192

api-js/src/loaders/domains/load-domain-by-domain.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports.domainLoaderByDomain = (query, userId, i18n) =>
99
cursor = await query`
1010
FOR domain IN domains
1111
FILTER domain.domain IN ${domains}
12-
RETURN domain
12+
RETURN MERGE({ id: domain._key}, domain)
1313
`
1414
} catch (err) {
1515
console.error(

api-js/src/loaders/domains/load-domain-by-key.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports.domainLoaderByKey = (query, userId, i18n) =>
99
cursor = await query`
1010
FOR domain IN domains
1111
FILTER domain._key IN ${ids}
12-
RETURN domain
12+
RETURN MERGE({ id: domain._key}, domain)
1313
`
1414
} catch (err) {
1515
console.error(

api-js/src/loaders/domains/load-domain-connections-by-organizations-id.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const domainLoaderConnectionsByOrgId = (
109109
${afterTemplate}
110110
${beforeTemplate}
111111
${limitTemplate}
112-
RETURN domain
112+
RETURN MERGE({ id: domain._key}, domain)
113113
)
114114
115115
LET hasNextPage = (LENGTH(
@@ -168,7 +168,6 @@ const domainLoaderConnectionsByOrgId = (
168168
}
169169

170170
const edges = domainsInfo.domains.map((domain) => {
171-
domain.id = domain._key
172171
return {
173172
cursor: toGlobalId('domains', domain._key),
174173
node: domain,

api-js/src/loaders/domains/load-domain-connections-by-user-id.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const domainLoaderConnectionsByUserId = (
104104
${afterTemplate}
105105
${beforeTemplate}
106106
${limitTemplate}
107-
RETURN domain
107+
RETURN MERGE({ id: domain._key}, domain)
108108
)
109109
110110
LET hasNextPage = (LENGTH(
@@ -163,7 +163,6 @@ const domainLoaderConnectionsByUserId = (
163163
}
164164

165165
const edges = domainsInfo.domains.map((domain) => {
166-
domain.id = domain._key
167166
return {
168167
cursor: toGlobalId('domains', domain._key),
169168
node: domain,

api-js/src/loaders/email-scan/__tests__/load-dkim-by-key.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('given the dkimLoaderByKey function', () => {
4949
const expectedCursor = await query`
5050
FOR dkimScan IN dkim
5151
SORT dkimScan._key ASC LIMIT 1
52-
RETURN dkimScan
52+
RETURN MERGE({ id: dkimScan._key}, dkimScan)
5353
`
5454
const expectedDkim = await expectedCursor.next()
5555

@@ -65,7 +65,7 @@ describe('given the dkimLoaderByKey function', () => {
6565
const expectedDkimScans = []
6666
const expectedCursor = await query`
6767
FOR dkimScan IN dkim
68-
RETURN dkimScan
68+
RETURN MERGE({ id: dkimScan._key}, dkimScan)
6969
`
7070

7171
while (expectedCursor.hasNext()) {

0 commit comments

Comments
 (0)