-
Notifications
You must be signed in to change notification settings - Fork 12
/
dataloader.go
443 lines (431 loc) · 32 KB
/
dataloader.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
package dataloader
import (
"context"
commonservice "github.com/openline-ai/openline-customer-os/packages/server/customer-os-common-module/service"
"net/http"
"time"
"github.com/graph-gophers/dataloader"
"github.com/openline-ai/openline-customer-os/packages/server/customer-os-api/service"
)
const defaultDataloaderWaitTime = 32 * time.Millisecond
type loadersString string
const loadersKey = loadersString("dataloaders")
type Loaders struct {
TagsForOrganization *dataloader.Loader
TagsForContact *dataloader.Loader
TagsForIssue *dataloader.Loader
TagsForLogEntry *dataloader.Loader
EmailsForContact *dataloader.Loader
EmailsForOrganization *dataloader.Loader
LocationsForContact *dataloader.Loader
LocationsForOrganization *dataloader.Loader
JobRolesForContact *dataloader.Loader
JobRolesForOrganization *dataloader.Loader
JobRolesForUser *dataloader.Loader
CalendarsForUser *dataloader.Loader
DomainsForOrganization *dataloader.Loader
InteractionEventsForInteractionSession *dataloader.Loader
InteractionSessionForInteractionEvent *dataloader.Loader
SentByParticipantsForInteractionEvent *dataloader.Loader
SentToParticipantsForInteractionEvent *dataloader.Loader
AttendedByParticipantsForInteractionSession *dataloader.Loader
ReplyToInteractionEventForInteractionEvent *dataloader.Loader
PhoneNumbersForOrganization *dataloader.Loader
PhoneNumbersForUser *dataloader.Loader
PhoneNumbersForContact *dataloader.Loader
NotedEntitiesForNote *dataloader.Loader
UsersForEmail *dataloader.Loader
UsersForPhoneNumber *dataloader.Loader
UsersForPlayer *dataloader.Loader
UserOwnerForOrganization *dataloader.Loader
UserOwnerForOpportunity *dataloader.Loader
UserCreatorForOpportunity *dataloader.Loader
UserCreatorForServiceLineItem *dataloader.Loader
UserCreatorForContract *dataloader.Loader
UserAuthorForLogEntry *dataloader.Loader
UserAuthorForComment *dataloader.Loader
User *dataloader.Loader
ContactsForEmail *dataloader.Loader
ContactsForPhoneNumber *dataloader.Loader
ContactCountForOrganization *dataloader.Loader
Organization *dataloader.Loader
OrganizationsForEmail *dataloader.Loader
OrganizationsForPhoneNumber *dataloader.Loader
SubsidiariesForOrganization *dataloader.Loader
SubsidiariesOfForOrganization *dataloader.Loader
SuggestedMergeToForOrganization *dataloader.Loader
DescribesForAnalysis *dataloader.Loader
DescribedByFor *dataloader.Loader
CreatedByParticipantsForMeeting *dataloader.Loader
AttendedByParticipantsForMeeting *dataloader.Loader
InteractionEventsForMeeting *dataloader.Loader
InteractionEventsForIssue *dataloader.Loader
CommentsForIssue *dataloader.Loader
NotesForMeeting *dataloader.Loader
AttachmentsForInteractionEvent *dataloader.Loader
AttachmentsForInteractionSession *dataloader.Loader
AttachmentsForMeeting *dataloader.Loader
AttachmentsForContract *dataloader.Loader
SocialsForContact *dataloader.Loader
SocialsForOrganization *dataloader.Loader
ExternalSystemsForComment *dataloader.Loader
ExternalSystemsForIssue *dataloader.Loader
ExternalSystemsForOrganization *dataloader.Loader
ExternalSystemsForLogEntry *dataloader.Loader
ExternalSystemsForMeeting *dataloader.Loader
ExternalSystemsForInteractionEvent *dataloader.Loader
ExternalSystemsForContract *dataloader.Loader
ExternalSystemsForOpportunity *dataloader.Loader
ExternalSystemsForServiceLineItem *dataloader.Loader
TimelineEventForTimelineEventId *dataloader.Loader
InboundCommsCountForOrganization *dataloader.Loader
OutboundCommsCountForOrganization *dataloader.Loader
OrganizationForJobRole *dataloader.Loader
OrganizationForInvoice *dataloader.Loader
OrganizationForSlackChannel *dataloader.Loader
ContactForJobRole *dataloader.Loader
IssueForInteractionEvent *dataloader.Loader
MeetingForInteractionEvent *dataloader.Loader
CountryForPhoneNumber *dataloader.Loader
ActionsForInteractionEvent *dataloader.Loader
ActionItemsForInteractionEvent *dataloader.Loader
SubmitterParticipantsForIssue *dataloader.Loader
ReporterParticipantsForIssue *dataloader.Loader
AssigneeParticipantsForIssue *dataloader.Loader
FollowerParticipantsForIssue *dataloader.Loader
ContractsForOrganization *dataloader.Loader
ContractForInvoice *dataloader.Loader
ServiceLineItemsForContract *dataloader.Loader
ServiceLineItemForInvoiceLine *dataloader.Loader
OpportunitiesForContract *dataloader.Loader
MasterPlanMilestonesForMasterPlan *dataloader.Loader
InvoiceLinesForInvoice *dataloader.Loader
OrganizationPlanMilestonesForOrganizationPlan *dataloader.Loader
OrdersForOrganization *dataloader.Loader
InvoicesForContract *dataloader.Loader
}
type tagBatcher struct {
tagService service.TagService
}
type emailBatcher struct {
emailService service.EmailService
}
type locationBatcher struct {
locationService service.LocationService
}
type socialBatcher struct {
socialService service.SocialService
}
type jobRoleBatcher struct {
jobRoleService service.JobRoleService
}
type calendarBatcher struct {
calendarService service.CalendarService
}
type domainBatcher struct {
domainService service.DomainService
}
type interactionEventBatcher struct {
interactionEventService service.InteractionEventService
}
type interactionSessionBatcher struct {
interactionSessionService service.InteractionSessionService
}
type interactionEventParticipantBatcher struct {
interactionEventService service.InteractionEventService
}
type interactionSessionParticipantBatcher struct {
interactionSessionService service.InteractionSessionService
}
type meetingParticipantBatcher struct {
meetingService service.MeetingService
}
type phoneNumberBatcher struct {
phoneNumberService service.PhoneNumberService
}
type notedEntityBatcher struct {
noteService service.NoteService
}
type userBatcher struct {
userService service.UserService
}
type contactBatcher struct {
contactService service.ContactService
}
type organizationBatcher struct {
organizationService service.OrganizationService
}
type analysisBatcher struct {
analysisService service.AnalysisService
}
type noteBatcher struct {
noteService service.NoteService
}
type attachmentBatcher struct {
attachmentService service.AttachmentService
}
type externalSystemBatcher struct {
externalSystemService service.ExternalSystemService
}
type timelineEventBatcher struct {
timelineEventService service.TimelineEventService
}
type issueBatcher struct {
issueService service.IssueService
}
type meetingBatcher struct {
meetingService service.MeetingService
}
type countryBatcher struct {
countryService service.CountryService
}
type actionBatcher struct {
actionService service.ActionService
}
type actionItemBatcher struct {
actionItemService service.ActionItemService
}
type issueParticipantBatcher struct {
issueService service.IssueService
}
type commentBatcher struct {
commentService service.CommentService
}
type contractBatcher struct {
contractService service.ContractService
}
type serviceLineItemBatcher struct {
serviceLineItemService commonservice.ServiceLineItemService
}
type opportunityBatcher struct {
opportunityService service.OpportunityService
}
type masterPlanBatcher struct {
masterPlanService service.MasterPlanService
}
type invoiceBatcher struct {
invoiceService commonservice.InvoiceService
}
type organizationPlanBatcher struct {
organizationPlanService service.OrganizationPlanService
}
type orderBatcher struct {
orderService service.OrderService
}
// NewDataLoader returns the instantiated Loaders struct for use in a request
func NewDataLoader(services *service.Services) *Loaders {
tagBatcher := &tagBatcher{
tagService: services.TagService,
}
emailBatcher := &emailBatcher{
emailService: services.EmailService,
}
locationBatcher := &locationBatcher{
locationService: services.LocationService,
}
socialBatcher := &socialBatcher{
socialService: services.SocialService,
}
jobRoleBatcher := &jobRoleBatcher{
jobRoleService: services.JobRoleService,
}
calendarBatcher := &calendarBatcher{
calendarService: services.CalendarService,
}
domainBatcher := &domainBatcher{
domainService: services.DomainService,
}
interactionEventBatcher := &interactionEventBatcher{
interactionEventService: services.InteractionEventService,
}
commentBatcher := &commentBatcher{
commentService: services.CommentService,
}
interactionSessionBatcher := &interactionSessionBatcher{
interactionSessionService: services.InteractionSessionService,
}
interactionEventParticipantBatcher := &interactionEventParticipantBatcher{
interactionEventService: services.InteractionEventService,
}
issueParticipantBatcher := &issueParticipantBatcher{
issueService: services.IssueService,
}
interactionSessionParticipantBatcher := &interactionSessionParticipantBatcher{
interactionSessionService: services.InteractionSessionService,
}
meetingParticipantBatcher := &meetingParticipantBatcher{
meetingService: services.MeetingService,
}
phoneNumberBatcher := &phoneNumberBatcher{
phoneNumberService: services.PhoneNumberService,
}
notedEntityBatcher := ¬edEntityBatcher{
noteService: services.NoteService,
}
userBatcher := &userBatcher{
userService: services.UserService,
}
contactBatcher := &contactBatcher{
contactService: services.ContactService,
}
organizationBatcher := &organizationBatcher{
organizationService: services.OrganizationService,
}
analysisBatcher := &analysisBatcher{
analysisService: services.AnalysisService,
}
noteBatcher := ¬eBatcher{
noteService: services.NoteService,
}
attachmentBatcher := attachmentBatcher{
attachmentService: services.AttachmentService,
}
externalSystemBatcher := externalSystemBatcher{
externalSystemService: services.ExternalSystemService,
}
timelineEventBatcher := timelineEventBatcher{
timelineEventService: services.TimelineEventService,
}
issueBatcher := issueBatcher{
issueService: services.IssueService,
}
meetingBatcher := meetingBatcher{
meetingService: services.MeetingService,
}
countryBatcher := countryBatcher{
countryService: services.CountryService,
}
actionBatcher := actionBatcher{
actionService: services.ActionService,
}
actionItemBatcher := actionItemBatcher{
actionItemService: services.ActionItemService,
}
contractBatcher := &contractBatcher{
contractService: services.ContractService,
}
serviceLineItemBatcher := &serviceLineItemBatcher{
serviceLineItemService: services.CommonServices.ServiceLineItemService,
}
opportunityBatcher := &opportunityBatcher{
opportunityService: services.OpportunityService,
}
masterPlanBatcher := &masterPlanBatcher{
masterPlanService: services.MasterPlanService,
}
invoiceBatcher := &invoiceBatcher{
invoiceService: services.CommonServices.InvoiceService,
}
organizationPlanBatcher := &organizationPlanBatcher{
organizationPlanService: services.OrganizationPlanService,
}
orderBatcher := &orderBatcher{
orderService: services.OrderService,
}
return &Loaders{
TagsForOrganization: dataloader.NewBatchedLoader(tagBatcher.getTagsForOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
TagsForContact: dataloader.NewBatchedLoader(tagBatcher.getTagsForContacts, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
TagsForIssue: dataloader.NewBatchedLoader(tagBatcher.getTagsForIssues, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
TagsForLogEntry: dataloader.NewBatchedLoader(tagBatcher.getTagsForLogEntries, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
EmailsForContact: dataloader.NewBatchedLoader(emailBatcher.getEmailsForContacts, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
EmailsForOrganization: dataloader.NewBatchedLoader(emailBatcher.getEmailsForOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
LocationsForContact: dataloader.NewBatchedLoader(locationBatcher.getLocationsForContacts, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
LocationsForOrganization: dataloader.NewBatchedLoader(locationBatcher.getLocationsForOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
JobRolesForContact: dataloader.NewBatchedLoader(jobRoleBatcher.getJobRolesForContacts, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
JobRolesForOrganization: dataloader.NewBatchedLoader(jobRoleBatcher.getJobRolesForOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
JobRolesForUser: dataloader.NewBatchedLoader(jobRoleBatcher.getJobRolesForUsers, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
CalendarsForUser: dataloader.NewBatchedLoader(calendarBatcher.getCalendarsForUsers, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
DomainsForOrganization: dataloader.NewBatchedLoader(domainBatcher.getDomainsForOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
InteractionEventsForInteractionSession: dataloader.NewBatchedLoader(interactionEventBatcher.getInteractionEventsForInteractionSessions, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
InteractionEventsForMeeting: dataloader.NewBatchedLoader(interactionEventBatcher.getInteractionEventsForMeetings, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
InteractionEventsForIssue: dataloader.NewBatchedLoader(interactionEventBatcher.getInteractionEventsForIssues, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
InteractionSessionForInteractionEvent: dataloader.NewBatchedLoader(interactionSessionBatcher.getInteractionSessionsForInteractionEvents, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
SentByParticipantsForInteractionEvent: dataloader.NewBatchedLoader(interactionEventParticipantBatcher.getSentByParticipantsForInteractionEvents, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
SentToParticipantsForInteractionEvent: dataloader.NewBatchedLoader(interactionEventParticipantBatcher.getSentToParticipantsForInteractionEvents, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
AttendedByParticipantsForInteractionSession: dataloader.NewBatchedLoader(interactionSessionParticipantBatcher.getAttendedByParticipantsForInteractionSessions, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
CreatedByParticipantsForMeeting: dataloader.NewBatchedLoader(meetingParticipantBatcher.getCreatedByParticipantsForMeeting, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
AttendedByParticipantsForMeeting: dataloader.NewBatchedLoader(meetingParticipantBatcher.getAttendedByParticipantsForMeeting, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
PhoneNumbersForOrganization: dataloader.NewBatchedLoader(phoneNumberBatcher.getPhoneNumbersForOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
PhoneNumbersForUser: dataloader.NewBatchedLoader(phoneNumberBatcher.getPhoneNumbersForUsers, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
PhoneNumbersForContact: dataloader.NewBatchedLoader(phoneNumberBatcher.getPhoneNumbersForContacts, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ReplyToInteractionEventForInteractionEvent: dataloader.NewBatchedLoader(interactionEventBatcher.getReplyToInteractionEventsForInteractionEvents, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
NotedEntitiesForNote: dataloader.NewBatchedLoader(notedEntityBatcher.getNotedEntitiesForNotes, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
UsersForEmail: dataloader.NewBatchedLoader(userBatcher.getUsersForEmails, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
UsersForPhoneNumber: dataloader.NewBatchedLoader(userBatcher.getUsersForPhoneNumbers, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
UsersForPlayer: dataloader.NewBatchedLoader(userBatcher.getUsersForPlayers, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
UserOwnerForOrganization: dataloader.NewBatchedLoader(userBatcher.getUserOwnersForOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
UserOwnerForOpportunity: dataloader.NewBatchedLoader(userBatcher.getUserOwnersForOpportunities, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
UserCreatorForOpportunity: dataloader.NewBatchedLoader(userBatcher.getUserCreatorsForOpportunities, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
UserCreatorForServiceLineItem: dataloader.NewBatchedLoader(userBatcher.getUserCreatorsForServiceLineItems, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
UserCreatorForContract: dataloader.NewBatchedLoader(userBatcher.getUserCreatorsForContracts, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
UserAuthorForLogEntry: dataloader.NewBatchedLoader(userBatcher.getUserAuthorsForLogEntries, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
UserAuthorForComment: dataloader.NewBatchedLoader(userBatcher.getUserAuthorsForComments, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
User: dataloader.NewBatchedLoader(userBatcher.getUsers, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ContactsForEmail: dataloader.NewBatchedLoader(contactBatcher.getContactsForEmails, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ContactsForPhoneNumber: dataloader.NewBatchedLoader(contactBatcher.getContactsForPhoneNumbers, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ContactCountForOrganization: dataloader.NewBatchedLoader(contactBatcher.getContactCountForOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
Organization: dataloader.NewBatchedLoader(organizationBatcher.getOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
OrganizationsForEmail: dataloader.NewBatchedLoader(organizationBatcher.getOrganizationsForEmails, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
OrganizationsForPhoneNumber: dataloader.NewBatchedLoader(organizationBatcher.getOrganizationsForPhoneNumbers, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
SubsidiariesForOrganization: dataloader.NewBatchedLoader(organizationBatcher.getSubsidiariesForOrganization, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
SubsidiariesOfForOrganization: dataloader.NewBatchedLoader(organizationBatcher.getSubsidiariesOfForOrganization, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(20*time.Millisecond), dataloader.WithWait(defaultDataloaderWaitTime)),
SuggestedMergeToForOrganization: dataloader.NewBatchedLoader(organizationBatcher.getSuggestedMergeToForOrganization, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
DescribesForAnalysis: dataloader.NewBatchedLoader(analysisBatcher.getDescribesForAnalysis, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
DescribedByFor: dataloader.NewBatchedLoader(analysisBatcher.getDescribedByFor, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
NotesForMeeting: dataloader.NewBatchedLoader(noteBatcher.getNotesForMeetings, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
AttachmentsForInteractionEvent: dataloader.NewBatchedLoader(attachmentBatcher.getAttachmentsForInteractionEvents, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
AttachmentsForInteractionSession: dataloader.NewBatchedLoader(attachmentBatcher.getAttachmentsForInteractionSessions, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
AttachmentsForMeeting: dataloader.NewBatchedLoader(attachmentBatcher.getAttachmentsForMeetings, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
AttachmentsForContract: dataloader.NewBatchedLoader(attachmentBatcher.getAttachmentsForContracts, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
SocialsForContact: dataloader.NewBatchedLoader(socialBatcher.getSocialsForContacts, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
SocialsForOrganization: dataloader.NewBatchedLoader(socialBatcher.getSocialsForOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ExternalSystemsForComment: dataloader.NewBatchedLoader(externalSystemBatcher.getExternalSystemsForComments, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ExternalSystemsForIssue: dataloader.NewBatchedLoader(externalSystemBatcher.getExternalSystemsForIssues, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ExternalSystemsForOrganization: dataloader.NewBatchedLoader(externalSystemBatcher.getExternalSystemsForOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ExternalSystemsForLogEntry: dataloader.NewBatchedLoader(externalSystemBatcher.getExternalSystemsForLogEntries, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ExternalSystemsForMeeting: dataloader.NewBatchedLoader(externalSystemBatcher.getExternalSystemsForMeetings, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ExternalSystemsForInteractionEvent: dataloader.NewBatchedLoader(externalSystemBatcher.getExternalSystemsForInteractionEvents, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ExternalSystemsForContract: dataloader.NewBatchedLoader(externalSystemBatcher.getExternalSystemsForContracts, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ExternalSystemsForOpportunity: dataloader.NewBatchedLoader(externalSystemBatcher.getExternalSystemsForOpportunities, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ExternalSystemsForServiceLineItem: dataloader.NewBatchedLoader(externalSystemBatcher.getExternalSystemsForServiceLineItems, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
TimelineEventForTimelineEventId: dataloader.NewBatchedLoader(timelineEventBatcher.getTimelineEventsForTimelineEventIds, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
InboundCommsCountForOrganization: dataloader.NewBatchedLoader(timelineEventBatcher.getInboundCommsCountForOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
OutboundCommsCountForOrganization: dataloader.NewBatchedLoader(timelineEventBatcher.getOutboundCommsCountForOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
OrganizationForJobRole: dataloader.NewBatchedLoader(organizationBatcher.getOrganizationsForJobRoles, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
OrganizationForInvoice: dataloader.NewBatchedLoader(organizationBatcher.getOrganizationsForInvoices, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
OrganizationForSlackChannel: dataloader.NewBatchedLoader(organizationBatcher.getOrganizationsForSlackChannels, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ContactForJobRole: dataloader.NewBatchedLoader(contactBatcher.getContactsForJobRoles, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
IssueForInteractionEvent: dataloader.NewBatchedLoader(issueBatcher.getIssuesForInteractionEvents, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
MeetingForInteractionEvent: dataloader.NewBatchedLoader(meetingBatcher.getMeetingsForInteractionEvents, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
CountryForPhoneNumber: dataloader.NewBatchedLoader(countryBatcher.getCountriesForPhoneNumbers, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ActionsForInteractionEvent: dataloader.NewBatchedLoader(actionBatcher.getActionsForInteractionEvents, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ActionItemsForInteractionEvent: dataloader.NewBatchedLoader(actionItemBatcher.getActionItemsForInteractionEvents, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
SubmitterParticipantsForIssue: dataloader.NewBatchedLoader(issueParticipantBatcher.getSubmitterParticipantsForIssues, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ReporterParticipantsForIssue: dataloader.NewBatchedLoader(issueParticipantBatcher.getReporterParticipantsForIssues, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
AssigneeParticipantsForIssue: dataloader.NewBatchedLoader(issueParticipantBatcher.getAssigneeParticipantsForIssues, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
FollowerParticipantsForIssue: dataloader.NewBatchedLoader(issueParticipantBatcher.getFollowerParticipantsForIssues, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
CommentsForIssue: dataloader.NewBatchedLoader(commentBatcher.getCommentsForIssues, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ContractsForOrganization: dataloader.NewBatchedLoader(contractBatcher.getContractsForOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ContractForInvoice: dataloader.NewBatchedLoader(contractBatcher.getContractsForInvoices, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ServiceLineItemsForContract: dataloader.NewBatchedLoader(serviceLineItemBatcher.getServiceLineItemsForContracts, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
ServiceLineItemForInvoiceLine: dataloader.NewBatchedLoader(serviceLineItemBatcher.getServiceLineItemForInvoiceLine, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
OpportunitiesForContract: dataloader.NewBatchedLoader(opportunityBatcher.getOpportunitiesForContracts, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
MasterPlanMilestonesForMasterPlan: dataloader.NewBatchedLoader(masterPlanBatcher.getMasterPlanMilestonesForMasterPlans, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
InvoiceLinesForInvoice: dataloader.NewBatchedLoader(invoiceBatcher.getInvoiceLinesForInvoice, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
OrganizationPlanMilestonesForOrganizationPlan: dataloader.NewBatchedLoader(organizationPlanBatcher.getOrganizationPlanMilestonesForOrganizationPlans, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
OrdersForOrganization: dataloader.NewBatchedLoader(orderBatcher.getOrdersForOrganizations, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
InvoicesForContract: dataloader.NewBatchedLoader(invoiceBatcher.getInvoicesForContract, dataloader.WithClearCacheOnBatch(), dataloader.WithWait(defaultDataloaderWaitTime)),
}
}
// Middleware injects a DataLoader into the request context, so it can be used later in the schema resolvers
func Middleware(loaders *Loaders, next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
nextCtx := context.WithValue(r.Context(), loadersKey, loaders)
r = r.WithContext(nextCtx)
next.ServeHTTP(w, r)
})
}
// For returns the dataloader for a given context
func For(ctx context.Context) *Loaders {
return ctx.Value(loadersKey).(*Loaders)
}