Skip to content

Commit d43aceb

Browse files
committed
Add [[nodiscard]] to clientgen types
1 parent 89fc567 commit d43aceb

File tree

7 files changed

+94
-94
lines changed

7 files changed

+94
-94
lines changed

samples/client/benchmark/BenchmarkClient.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ namespace graphql::client {
5050
namespace benchmark {
5151

5252
// Return the original text of the request document.
53-
const std::string& GetRequestText() noexcept;
53+
[[nodiscard]] const std::string& GetRequestText() noexcept;
5454

5555
// Return a pre-parsed, pre-validated request object.
56-
const peg::ast& GetRequestObject() noexcept;
56+
[[nodiscard]] const peg::ast& GetRequestObject() noexcept;
5757

5858
} // namespace benchmark
5959

@@ -63,20 +63,20 @@ using benchmark::GetRequestText;
6363
using benchmark::GetRequestObject;
6464

6565
// Return the name of this operation in the shared request document.
66-
const std::string& GetOperationName() noexcept;
66+
[[nodiscard]] const std::string& GetOperationName() noexcept;
6767

68-
struct Response
68+
struct [[nodiscard]] Response
6969
{
70-
struct appointments_AppointmentConnection
70+
struct [[nodiscard]] appointments_AppointmentConnection
7171
{
72-
struct pageInfo_PageInfo
72+
struct [[nodiscard]] pageInfo_PageInfo
7373
{
7474
bool hasNextPage {};
7575
};
7676

77-
struct edges_AppointmentEdge
77+
struct [[nodiscard]] edges_AppointmentEdge
7878
{
79-
struct node_Appointment
79+
struct [[nodiscard]] node_Appointment
8080
{
8181
response::IdType id {};
8282
std::optional<response::Value> when {};
@@ -94,7 +94,7 @@ struct Response
9494
appointments_AppointmentConnection appointments {};
9595
};
9696

97-
Response parseResponse(response::Value&& response);
97+
[[nodiscard]] Response parseResponse(response::Value&& response);
9898

9999
} // namespace query::Query
100100
} // namespace graphql::client

samples/client/multiple/MultipleQueriesClient.h

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ namespace graphql::client {
112112
namespace multiple {
113113

114114
// Return the original text of the request document.
115-
const std::string& GetRequestText() noexcept;
115+
[[nodiscard]] const std::string& GetRequestText() noexcept;
116116

117117
// Return a pre-parsed, pre-validated request object.
118-
const peg::ast& GetRequestObject() noexcept;
118+
[[nodiscard]] const peg::ast& GetRequestObject() noexcept;
119119

120120
enum class [[nodiscard]] TaskState
121121
{
@@ -125,7 +125,7 @@ enum class [[nodiscard]] TaskState
125125
Unassigned,
126126
};
127127

128-
struct CompleteTaskInput
128+
struct [[nodiscard]] CompleteTaskInput
129129
{
130130
response::IdType id {};
131131
std::optional<TaskState> testTaskState {};
@@ -141,15 +141,15 @@ using multiple::GetRequestText;
141141
using multiple::GetRequestObject;
142142

143143
// Return the name of this operation in the shared request document.
144-
const std::string& GetOperationName() noexcept;
144+
[[nodiscard]] const std::string& GetOperationName() noexcept;
145145

146-
struct Response
146+
struct [[nodiscard]] Response
147147
{
148-
struct appointments_AppointmentConnection
148+
struct [[nodiscard]] appointments_AppointmentConnection
149149
{
150-
struct edges_AppointmentEdge
150+
struct [[nodiscard]] edges_AppointmentEdge
151151
{
152-
struct node_Appointment
152+
struct [[nodiscard]] node_Appointment
153153
{
154154
response::IdType id {};
155155
std::optional<std::string> subject {};
@@ -167,7 +167,7 @@ struct Response
167167
appointments_AppointmentConnection appointments {};
168168
};
169169

170-
Response parseResponse(response::Value&& response);
170+
[[nodiscard]] Response parseResponse(response::Value&& response);
171171

172172
} // namespace query::Appointments
173173

@@ -177,15 +177,15 @@ using multiple::GetRequestText;
177177
using multiple::GetRequestObject;
178178

179179
// Return the name of this operation in the shared request document.
180-
const std::string& GetOperationName() noexcept;
180+
[[nodiscard]] const std::string& GetOperationName() noexcept;
181181

182-
struct Response
182+
struct [[nodiscard]] Response
183183
{
184-
struct tasks_TaskConnection
184+
struct [[nodiscard]] tasks_TaskConnection
185185
{
186-
struct edges_TaskEdge
186+
struct [[nodiscard]] edges_TaskEdge
187187
{
188-
struct node_Task
188+
struct [[nodiscard]] node_Task
189189
{
190190
response::IdType id {};
191191
std::optional<std::string> title {};
@@ -202,7 +202,7 @@ struct Response
202202
tasks_TaskConnection tasks {};
203203
};
204204

205-
Response parseResponse(response::Value&& response);
205+
[[nodiscard]] Response parseResponse(response::Value&& response);
206206

207207
} // namespace query::Tasks
208208

@@ -212,15 +212,15 @@ using multiple::GetRequestText;
212212
using multiple::GetRequestObject;
213213

214214
// Return the name of this operation in the shared request document.
215-
const std::string& GetOperationName() noexcept;
215+
[[nodiscard]] const std::string& GetOperationName() noexcept;
216216

217-
struct Response
217+
struct [[nodiscard]] Response
218218
{
219-
struct unreadCounts_FolderConnection
219+
struct [[nodiscard]] unreadCounts_FolderConnection
220220
{
221-
struct edges_FolderEdge
221+
struct [[nodiscard]] edges_FolderEdge
222222
{
223-
struct node_Folder
223+
struct [[nodiscard]] node_Folder
224224
{
225225
response::IdType id {};
226226
std::optional<std::string> name {};
@@ -237,7 +237,7 @@ struct Response
237237
unreadCounts_FolderConnection unreadCounts {};
238238
};
239239

240-
Response parseResponse(response::Value&& response);
240+
[[nodiscard]] Response parseResponse(response::Value&& response);
241241

242242
} // namespace query::UnreadCounts
243243

@@ -247,13 +247,13 @@ using multiple::GetRequestText;
247247
using multiple::GetRequestObject;
248248

249249
// Return the name of this operation in the shared request document.
250-
const std::string& GetOperationName() noexcept;
250+
[[nodiscard]] const std::string& GetOperationName() noexcept;
251251

252252
using multiple::TaskState;
253253

254-
struct Response
254+
struct [[nodiscard]] Response
255255
{
256-
struct anyType_UnionType
256+
struct [[nodiscard]] anyType_UnionType
257257
{
258258
std::string _typename {};
259259
response::IdType id {};
@@ -269,7 +269,7 @@ struct Response
269269
std::optional<std::string> default_ {};
270270
};
271271

272-
Response parseResponse(response::Value&& response);
272+
[[nodiscard]] Response parseResponse(response::Value&& response);
273273

274274
} // namespace query::Miscellaneous
275275

@@ -279,25 +279,25 @@ using multiple::GetRequestText;
279279
using multiple::GetRequestObject;
280280

281281
// Return the name of this operation in the shared request document.
282-
const std::string& GetOperationName() noexcept;
282+
[[nodiscard]] const std::string& GetOperationName() noexcept;
283283

284284
using multiple::TaskState;
285285

286286
using multiple::CompleteTaskInput;
287287

288-
struct Variables
288+
struct [[nodiscard]] Variables
289289
{
290290
std::unique_ptr<CompleteTaskInput> input {};
291291
bool skipClientMutationId {};
292292
};
293293

294-
response::Value serializeVariables(Variables&& variables);
294+
[[nodiscard]] response::Value serializeVariables(Variables&& variables);
295295

296-
struct Response
296+
struct [[nodiscard]] Response
297297
{
298-
struct completedTask_CompleteTaskPayload
298+
struct [[nodiscard]] completedTask_CompleteTaskPayload
299299
{
300-
struct completedTask_Task
300+
struct [[nodiscard]] completedTask_Task
301301
{
302302
response::IdType completedTaskId {};
303303
std::optional<std::string> title {};
@@ -311,7 +311,7 @@ struct Response
311311
completedTask_CompleteTaskPayload completedTask {};
312312
};
313313

314-
Response parseResponse(response::Value&& response);
314+
[[nodiscard]] Response parseResponse(response::Value&& response);
315315

316316
} // namespace mutation::CompleteTaskMutation
317317
} // namespace graphql::client

samples/client/mutate/MutateClient.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ namespace graphql::client {
4545
namespace mutate {
4646

4747
// Return the original text of the request document.
48-
const std::string& GetRequestText() noexcept;
48+
[[nodiscard]] const std::string& GetRequestText() noexcept;
4949

5050
// Return a pre-parsed, pre-validated request object.
51-
const peg::ast& GetRequestObject() noexcept;
51+
[[nodiscard]] const peg::ast& GetRequestObject() noexcept;
5252

5353
enum class [[nodiscard]] TaskState
5454
{
@@ -58,7 +58,7 @@ enum class [[nodiscard]] TaskState
5858
Unassigned,
5959
};
6060

61-
struct CompleteTaskInput
61+
struct [[nodiscard]] CompleteTaskInput
6262
{
6363
response::IdType id {};
6464
std::optional<TaskState> testTaskState {};
@@ -74,25 +74,25 @@ using mutate::GetRequestText;
7474
using mutate::GetRequestObject;
7575

7676
// Return the name of this operation in the shared request document.
77-
const std::string& GetOperationName() noexcept;
77+
[[nodiscard]] const std::string& GetOperationName() noexcept;
7878

7979
using mutate::TaskState;
8080

8181
using mutate::CompleteTaskInput;
8282

83-
struct Variables
83+
struct [[nodiscard]] Variables
8484
{
8585
std::unique_ptr<CompleteTaskInput> input {};
8686
bool skipClientMutationId {};
8787
};
8888

89-
response::Value serializeVariables(Variables&& variables);
89+
[[nodiscard]] response::Value serializeVariables(Variables&& variables);
9090

91-
struct Response
91+
struct [[nodiscard]] Response
9292
{
93-
struct completedTask_CompleteTaskPayload
93+
struct [[nodiscard]] completedTask_CompleteTaskPayload
9494
{
95-
struct completedTask_Task
95+
struct [[nodiscard]] completedTask_Task
9696
{
9797
response::IdType completedTaskId {};
9898
std::optional<std::string> title {};
@@ -106,7 +106,7 @@ struct Response
106106
completedTask_CompleteTaskPayload completedTask {};
107107
};
108108

109-
Response parseResponse(response::Value&& response);
109+
[[nodiscard]] Response parseResponse(response::Value&& response);
110110

111111
} // namespace mutation::CompleteTaskMutation
112112
} // namespace graphql::client

samples/client/nestedinput/NestedInputClient.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,32 @@ namespace graphql::client {
3939
namespace nestedinput {
4040

4141
// Return the original text of the request document.
42-
const std::string& GetRequestText() noexcept;
42+
[[nodiscard]] const std::string& GetRequestText() noexcept;
4343

4444
// Return a pre-parsed, pre-validated request object.
45-
const peg::ast& GetRequestObject() noexcept;
45+
[[nodiscard]] const peg::ast& GetRequestObject() noexcept;
4646

47-
struct InputA
47+
struct [[nodiscard]] InputA
4848
{
4949
bool a {};
5050
};
5151

52-
struct InputB
52+
struct [[nodiscard]] InputB
5353
{
5454
double b {};
5555
};
5656

5757
struct InputBC;
5858

59-
struct InputABCD
59+
struct [[nodiscard]] InputABCD
6060
{
6161
std::string d {};
6262
InputA a {};
6363
InputB b {};
6464
std::vector<InputBC> bc {};
6565
};
6666

67-
struct InputBC
67+
struct [[nodiscard]] InputBC
6868
{
6969
response::IdType c {};
7070
InputB b {};
@@ -78,25 +78,25 @@ using nestedinput::GetRequestText;
7878
using nestedinput::GetRequestObject;
7979

8080
// Return the name of this operation in the shared request document.
81-
const std::string& GetOperationName() noexcept;
81+
[[nodiscard]] const std::string& GetOperationName() noexcept;
8282

8383
using nestedinput::InputA;
8484
using nestedinput::InputB;
8585
using nestedinput::InputABCD;
8686
using nestedinput::InputBC;
8787

88-
struct Variables
88+
struct [[nodiscard]] Variables
8989
{
9090
InputABCD stream {};
9191
};
9292

93-
response::Value serializeVariables(Variables&& variables);
93+
[[nodiscard]] response::Value serializeVariables(Variables&& variables);
9494

95-
struct Response
95+
struct [[nodiscard]] Response
9696
{
97-
struct control_Control
97+
struct [[nodiscard]] control_Control
9898
{
99-
struct test_Output
99+
struct [[nodiscard]] test_Output
100100
{
101101
std::optional<bool> id {};
102102
};
@@ -107,7 +107,7 @@ struct Response
107107
control_Control control {};
108108
};
109109

110-
Response parseResponse(response::Value&& response);
110+
[[nodiscard]] Response parseResponse(response::Value&& response);
111111

112112
} // namespace query::testQuery
113113
} // namespace graphql::client

0 commit comments

Comments
 (0)