@@ -56,13 +56,13 @@ void Query::loadAppointments(const std::shared_ptr<service::RequestState>& state
56
56
}
57
57
}
58
58
59
- std::shared_ptr<Appointment> Query::findAppointment (const std::shared_ptr< service::RequestState>& state , const std::vector<uint8_t >& id) const
59
+ std::shared_ptr<Appointment> Query::findAppointment (const service::FieldParams& params , const std::vector<uint8_t >& id) const
60
60
{
61
- loadAppointments (state);
61
+ loadAppointments (params. state );
62
62
63
63
for (const auto & appointment : _appointments)
64
64
{
65
- auto appointmentId = appointment->getId (state ).get ();
65
+ auto appointmentId = appointment->getId (params ).get ();
66
66
67
67
if (appointmentId == id)
68
68
{
@@ -90,13 +90,13 @@ void Query::loadTasks(const std::shared_ptr<service::RequestState>& state) const
90
90
}
91
91
}
92
92
93
- std::shared_ptr<Task> Query::findTask (const std::shared_ptr< service::RequestState>& state , const std::vector<uint8_t >& id) const
93
+ std::shared_ptr<Task> Query::findTask (const service::FieldParams& params , const std::vector<uint8_t >& id) const
94
94
{
95
- loadTasks (state);
95
+ loadTasks (params. state );
96
96
97
97
for (const auto & task : _tasks)
98
98
{
99
- auto taskId = task->getId (state ).get ();
99
+ auto taskId = task->getId (params ).get ();
100
100
101
101
if (taskId == id)
102
102
{
@@ -124,13 +124,13 @@ void Query::loadUnreadCounts(const std::shared_ptr<service::RequestState>& state
124
124
}
125
125
}
126
126
127
- std::shared_ptr<Folder> Query::findUnreadCount (const std::shared_ptr< service::RequestState>& state , const std::vector<uint8_t >& id) const
127
+ std::shared_ptr<Folder> Query::findUnreadCount (const service::FieldParams& params , const std::vector<uint8_t >& id) const
128
128
{
129
- loadUnreadCounts (state);
129
+ loadUnreadCounts (params. state );
130
130
131
131
for (const auto & folder : _unreadCounts)
132
132
{
133
- auto folderId = folder->getId (state ).get ();
133
+ auto folderId = folder->getId (params ).get ();
134
134
135
135
if (folderId == id)
136
136
{
@@ -141,26 +141,26 @@ std::shared_ptr<Folder> Query::findUnreadCount(const std::shared_ptr<service::Re
141
141
return nullptr ;
142
142
}
143
143
144
- std::future<std::shared_ptr<service::Object>> Query::getNode (const std::shared_ptr< service::RequestState>& state , std::vector<uint8_t >&& id) const
144
+ std::future<std::shared_ptr<service::Object>> Query::getNode (const service::FieldParams& params , std::vector<uint8_t >&& id) const
145
145
{
146
146
std::promise<std::shared_ptr<service::Object>> promise;
147
- auto appointment = findAppointment (state , id);
147
+ auto appointment = findAppointment (params , id);
148
148
149
149
if (appointment)
150
150
{
151
151
promise.set_value (appointment);
152
152
return promise.get_future ();
153
153
}
154
154
155
- auto task = findTask (state , id);
155
+ auto task = findTask (params , id);
156
156
157
157
if (task)
158
158
{
159
159
promise.set_value (task);
160
160
return promise.get_future ();
161
161
}
162
162
163
- auto folder = findUnreadCount (state , id);
163
+ auto folder = findUnreadCount (params , id);
164
164
165
165
if (folder)
166
166
{
@@ -189,14 +189,24 @@ struct EdgeConstraints
189
189
auto itrFirst = _objects.cbegin ();
190
190
auto itrLast = _objects.cend ();
191
191
192
+ const response::Value unusedDirectives;
193
+ const service::SelectionSetParams selectionSetParams {
194
+ _state,
195
+ unusedDirectives,
196
+ unusedDirectives,
197
+ unusedDirectives,
198
+ unusedDirectives,
199
+ };
200
+ const service::FieldParams fieldParams (selectionSetParams, {});
201
+
192
202
if (after)
193
203
{
194
204
const auto & encoded = after->get <const response::StringType&>();
195
205
auto afterId = service::Base64::fromBase64 (encoded.c_str (), encoded.size ());
196
206
auto itrAfter = std::find_if (itrFirst, itrLast,
197
- [this , &afterId](const std::shared_ptr<_Object>& entry)
207
+ [this , &fieldParams, & afterId](const std::shared_ptr<_Object>& entry)
198
208
{
199
- return entry->getId (_state ).get () == afterId;
209
+ return entry->getId (fieldParams ).get () == afterId;
200
210
});
201
211
202
212
if (itrAfter != itrLast)
@@ -210,9 +220,9 @@ struct EdgeConstraints
210
220
const auto & encoded = before->get <const response::StringType&>();
211
221
auto beforeId = service::Base64::fromBase64 (encoded.c_str (), encoded.size ());
212
222
auto itrBefore = std::find_if (itrFirst, itrLast,
213
- [this , &beforeId](const std::shared_ptr<_Object>& entry)
223
+ [this , &fieldParams, & beforeId](const std::shared_ptr<_Object>& entry)
214
224
{
215
- return entry->getId (_state ).get () == beforeId;
225
+ return entry->getId (fieldParams ).get () == beforeId;
216
226
});
217
227
218
228
if (itrBefore != itrLast)
@@ -262,94 +272,97 @@ struct EdgeConstraints
262
272
}
263
273
264
274
private:
265
- std::shared_ptr<service::RequestState> _state;
275
+ const std::shared_ptr<service::RequestState>& _state;
266
276
const vec_type& _objects;
267
277
};
268
278
269
- std::future<std::shared_ptr<object::AppointmentConnection>> Query::getAppointments (const std::shared_ptr< service::RequestState>& state , std::unique_ptr<int >&& first, std::unique_ptr<response::Value>&& after, std::unique_ptr<int >&& last, std::unique_ptr<response::Value>&& before) const
279
+ std::future<std::shared_ptr<object::AppointmentConnection>> Query::getAppointments (const service::FieldParams& params , std::unique_ptr<int >&& first, std::unique_ptr<response::Value>&& after, std::unique_ptr<int >&& last, std::unique_ptr<response::Value>&& before) const
270
280
{
271
281
auto spThis = shared_from_this ();
282
+ auto state = params.state ;
272
283
return std::async (std::launch::async,
273
- [this , spThis]( const std::shared_ptr<service::RequestState>& stateWrapped, std::unique_ptr<int >&& firstWrapped, std::unique_ptr<response::Value>&& afterWrapped, std::unique_ptr<int >&& lastWrapped, std::unique_ptr<response::Value>&& beforeWrapped)
284
+ [this , spThis, state]( std::unique_ptr<int >&& firstWrapped, std::unique_ptr<response::Value>&& afterWrapped, std::unique_ptr<int >&& lastWrapped, std::unique_ptr<response::Value>&& beforeWrapped)
274
285
{
275
- loadAppointments (stateWrapped );
286
+ loadAppointments (state );
276
287
277
- EdgeConstraints<Appointment, AppointmentConnection> constraints (stateWrapped , _appointments);
288
+ EdgeConstraints<Appointment, AppointmentConnection> constraints (state , _appointments);
278
289
auto connection = constraints (firstWrapped.get (), afterWrapped.get (), lastWrapped.get (), beforeWrapped.get ());
279
290
280
291
return std::static_pointer_cast<object::AppointmentConnection>(connection);
281
- }, std::move (state), std::move ( first), std::move (after), std::move (last), std::move (before));
292
+ }, std::move (first), std::move (after), std::move (last), std::move (before));
282
293
}
283
294
284
- std::future<std::shared_ptr<object::TaskConnection>> Query::getTasks (const std::shared_ptr< service::RequestState>& state , std::unique_ptr<int >&& first, std::unique_ptr<response::Value>&& after, std::unique_ptr<int >&& last, std::unique_ptr<response::Value>&& before) const
295
+ std::future<std::shared_ptr<object::TaskConnection>> Query::getTasks (const service::FieldParams& params , std::unique_ptr<int >&& first, std::unique_ptr<response::Value>&& after, std::unique_ptr<int >&& last, std::unique_ptr<response::Value>&& before) const
285
296
{
286
297
auto spThis = shared_from_this ();
298
+ auto state = params.state ;
287
299
return std::async (std::launch::async,
288
- [this , spThis]( const std::shared_ptr<service::RequestState>& stateWrapped, std::unique_ptr<int >&& firstWrapped, std::unique_ptr<response::Value>&& afterWrapped, std::unique_ptr<int >&& lastWrapped, std::unique_ptr<response::Value>&& beforeWrapped)
300
+ [this , spThis, state]( std::unique_ptr<int >&& firstWrapped, std::unique_ptr<response::Value>&& afterWrapped, std::unique_ptr<int >&& lastWrapped, std::unique_ptr<response::Value>&& beforeWrapped)
289
301
{
290
- loadTasks (stateWrapped );
302
+ loadTasks (state );
291
303
292
- EdgeConstraints<Task, TaskConnection> constraints (stateWrapped , _tasks);
304
+ EdgeConstraints<Task, TaskConnection> constraints (state , _tasks);
293
305
auto connection = constraints (firstWrapped.get (), afterWrapped.get (), lastWrapped.get (), beforeWrapped.get ());
294
306
295
307
return std::static_pointer_cast<object::TaskConnection>(connection);
296
- }, std::move (state), std::move ( first), std::move (after), std::move (last), std::move (before));
308
+ }, std::move (first), std::move (after), std::move (last), std::move (before));
297
309
}
298
310
299
- std::future<std::shared_ptr<object::FolderConnection>> Query::getUnreadCounts (const std::shared_ptr< service::RequestState>& state , std::unique_ptr<int >&& first, std::unique_ptr<response::Value>&& after, std::unique_ptr<int >&& last, std::unique_ptr<response::Value>&& before) const
311
+ std::future<std::shared_ptr<object::FolderConnection>> Query::getUnreadCounts (const service::FieldParams& params , std::unique_ptr<int >&& first, std::unique_ptr<response::Value>&& after, std::unique_ptr<int >&& last, std::unique_ptr<response::Value>&& before) const
300
312
{
301
313
auto spThis = shared_from_this ();
314
+ auto state = params.state ;
302
315
return std::async (std::launch::async,
303
- [this , spThis]( const std::shared_ptr<service::RequestState>& stateWrapped, std::unique_ptr<int >&& firstWrapped, std::unique_ptr<response::Value>&& afterWrapped, std::unique_ptr<int >&& lastWrapped, std::unique_ptr<response::Value>&& beforeWrapped)
316
+ [this , spThis, state]( std::unique_ptr<int >&& firstWrapped, std::unique_ptr<response::Value>&& afterWrapped, std::unique_ptr<int >&& lastWrapped, std::unique_ptr<response::Value>&& beforeWrapped)
304
317
{
305
- loadUnreadCounts (stateWrapped );
318
+ loadUnreadCounts (state );
306
319
307
- EdgeConstraints<Folder, FolderConnection> constraints (stateWrapped , _unreadCounts);
320
+ EdgeConstraints<Folder, FolderConnection> constraints (state , _unreadCounts);
308
321
auto connection = constraints (firstWrapped.get (), afterWrapped.get (), lastWrapped.get (), beforeWrapped.get ());
309
322
310
323
return std::static_pointer_cast<object::FolderConnection>(connection);
311
- }, std::move (state), std::move ( first), std::move (after), std::move (last), std::move (before));
324
+ }, std::move (first), std::move (after), std::move (last), std::move (before));
312
325
}
313
326
314
- std::future<std::vector<std::shared_ptr<object::Appointment>>> Query::getAppointmentsById (const std::shared_ptr< service::RequestState>& state , std::vector<std::vector<uint8_t >>&& ids) const
327
+ std::future<std::vector<std::shared_ptr<object::Appointment>>> Query::getAppointmentsById (const service::FieldParams& params , std::vector<std::vector<uint8_t >>&& ids) const
315
328
{
316
329
std::promise<std::vector<std::shared_ptr<object::Appointment>>> promise;
317
330
std::vector<std::shared_ptr<object::Appointment>> result (ids.size ());
318
331
319
332
std::transform (ids.cbegin (), ids.cend (), result.begin (),
320
- [this , &state ](const std::vector<uint8_t >& id)
333
+ [this , ¶ms ](const std::vector<uint8_t >& id)
321
334
{
322
- return std::static_pointer_cast<object::Appointment>(findAppointment (state , id));
335
+ return std::static_pointer_cast<object::Appointment>(findAppointment (params , id));
323
336
});
324
337
promise.set_value (std::move (result));
325
338
326
339
return promise.get_future ();
327
340
}
328
341
329
- std::future<std::vector<std::shared_ptr<object::Task>>> Query::getTasksById (const std::shared_ptr< service::RequestState>& state , std::vector<std::vector<uint8_t >>&& ids) const
342
+ std::future<std::vector<std::shared_ptr<object::Task>>> Query::getTasksById (const service::FieldParams& params , std::vector<std::vector<uint8_t >>&& ids) const
330
343
{
331
344
std::promise<std::vector<std::shared_ptr<object::Task>>> promise;
332
345
std::vector<std::shared_ptr<object::Task>> result (ids.size ());
333
346
334
347
std::transform (ids.cbegin (), ids.cend (), result.begin (),
335
- [this , &state ](const std::vector<uint8_t >& id)
348
+ [this , ¶ms ](const std::vector<uint8_t >& id)
336
349
{
337
- return std::static_pointer_cast<object::Task>(findTask (state , id));
350
+ return std::static_pointer_cast<object::Task>(findTask (params , id));
338
351
});
339
352
promise.set_value (std::move (result));
340
353
341
354
return promise.get_future ();
342
355
}
343
356
344
- std::future<std::vector<std::shared_ptr<object::Folder>>> Query::getUnreadCountsById (const std::shared_ptr< service::RequestState>& state , std::vector<std::vector<uint8_t >>&& ids) const
357
+ std::future<std::vector<std::shared_ptr<object::Folder>>> Query::getUnreadCountsById (const service::FieldParams& params , std::vector<std::vector<uint8_t >>&& ids) const
345
358
{
346
359
std::promise<std::vector<std::shared_ptr<object::Folder>>> promise;
347
360
std::vector<std::shared_ptr<object::Folder>> result (ids.size ());
348
361
349
362
std::transform (ids.cbegin (), ids.cend (), result.begin (),
350
- [this , &state ](const std::vector<uint8_t >& id)
363
+ [this , ¶ms ](const std::vector<uint8_t >& id)
351
364
{
352
- return std::static_pointer_cast<object::Folder>(findUnreadCount (state , id));
365
+ return std::static_pointer_cast<object::Folder>(findUnreadCount (params , id));
353
366
});
354
367
promise.set_value (std::move (result));
355
368
@@ -361,7 +374,7 @@ Mutation::Mutation(completeTaskMutation&& mutateCompleteTask)
361
374
{
362
375
}
363
376
364
- std::future<std::shared_ptr<object::CompleteTaskPayload>> Mutation::getCompleteTask (const std::shared_ptr< service::RequestState>& state , CompleteTaskInput&& input) const
377
+ std::future<std::shared_ptr<object::CompleteTaskPayload>> Mutation::getCompleteTask (const service::FieldParams& params , CompleteTaskInput&& input) const
365
378
{
366
379
std::promise<std::shared_ptr<object::CompleteTaskPayload>> promise;
367
380
0 commit comments