Skip to content

Commit c21f415

Browse files
committed
Update docs for next release
1 parent af31c68 commit c21f415

File tree

5 files changed

+45
-39
lines changed

5 files changed

+45
-39
lines changed

doc/awaitable.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ specifically a type-erased `graphql::service::await_async` class in
88
[GraphQLService.h](../include/graphqlservice/GraphQLService.h):
99
```cpp
1010
// Type-erased awaitable.
11-
class await_async final
11+
class [[nodiscard]] await_async final
1212
{
1313
private:
14-
struct Concept
14+
struct [[nodiscard]] Concept
1515
{
1616
virtual ~Concept() = default;
1717

18-
virtual bool await_ready() const = 0;
18+
[[nodiscard]] virtual bool await_ready() const = 0;
1919
virtual void await_suspend(coro::coroutine_handle<> h) const = 0;
2020
virtual void await_resume() const = 0;
2121
};
@@ -71,22 +71,22 @@ Many APIs which used to return some sort of `std::future` now return an alias fo
7171
`graphql::internal::Awaitable<...>`. This template is defined in [Awaitable.h](../include/graphqlservice/internal/Awaitable.h):
7272
```cpp
7373
template <typename T>
74-
class Awaitable
74+
class [[nodiscard]] Awaitable
7575
{
7676
public:
7777
Awaitable(std::future<T> value)
7878
: _value { std::move(value) }
7979
{
8080
}
8181

82-
T get()
82+
[[nodiscard]] T get()
8383
{
8484
return _value.get();
8585
}
8686

8787
struct promise_type
8888
{
89-
Awaitable get_return_object() noexcept
89+
[[nodiscard]] Awaitable get_return_object() noexcept
9090
{
9191
return { _promise.get_future() };
9292
}
@@ -105,7 +105,7 @@ public:
105105

106106
};
107107

108-
constexpr bool await_ready() const noexcept
108+
[[nodiscard]] constexpr bool await_ready() const noexcept
109109
{
110110
return true;
111111
}
@@ -115,7 +115,7 @@ public:
115115
h.resume();
116116
}
117117

118-
T await_resume()
118+
[[nodiscard]] T await_resume()
119119
{
120120
return _value.get();
121121
}

doc/fieldparams.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The `graphql::service::FieldParams` struct is declared in [GraphQLService.h](../
2121
```cpp
2222
// Pass a common bundle of parameters to all of the generated Object::getField accessors in a
2323
// SelectionSet
24-
struct SelectionSetParams
24+
struct [[nodiscard]] SelectionSetParams
2525
{
2626
// Context for this selection set.
2727
const ResolverContext resolverContext;
@@ -46,7 +46,7 @@ struct SelectionSetParams
4646
};
4747

4848
// Pass a common bundle of parameters to all of the generated Object::getField accessors.
49-
struct FieldParams : SelectionSetParams
49+
struct [[nodiscard]] FieldParams : SelectionSetParams
5050
{
5151
GRAPHQLSERVICE_EXPORT explicit FieldParams(
5252
SelectionSetParams&& selectionSetParams, Directives directives);
@@ -64,8 +64,7 @@ The `SelectionSetParams::resolverContext` enum member informs the `getField`
6464
accessors about what type of operation is being resolved:
6565
```cpp
6666
// Resolvers may be called in multiple different Operation contexts.
67-
enum class ResolverContext
68-
{
67+
enum class [[nodiscard]] ResolverContext {
6968
// Resolving a Query operation.
7069
Query,
7170

@@ -95,8 +94,9 @@ The `SelectionSetParams::state` member is a reference to the
9594
// any per-request state that you want to maintain throughout the request (e.g. optimizing or
9695
// batching backend requests), you can inherit from RequestState and pass it to Request::resolve to
9796
// correlate the asynchronous/recursive callbacks and accumulate state in it.
98-
struct RequestState : std::enable_shared_from_this<RequestState>
97+
struct [[nodiscard]] RequestState : std::enable_shared_from_this<RequestState>
9998
{
99+
virtual ~RequestState() = default;
100100
};
101101
```
102102

doc/json.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ to some other output mechanism, without building a single string buffer for the
4646
document in memory. For example, you might use this to write directly to a buffered IPC pipe
4747
or network connection:
4848
```cpp
49-
class Writer final
49+
class [[nodiscard]] Writer final
5050
{
5151
private:
5252
struct Concept

doc/responses.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ represented in GraphQL, as of the
1010
[October 2021 spec](https://spec.graphql.org/October2021/#sec-Serialization-Format):
1111

1212
```c++
13-
enum class Type : uint8_t
14-
{
15-
Map, // JSON Object
16-
List, // JSON Array
17-
String, // JSON String
18-
Null, // JSON null
19-
Boolean, // JSON true or false
20-
Int, // JSON Number
21-
Float, // JSON Number
22-
EnumValue, // JSON String
23-
Scalar, // JSON any type
13+
enum class [[nodiscard]] Type : std::uint8_t {
14+
Map, // JSON Object
15+
List, // JSON Array
16+
String, // JSON String
17+
Null, // JSON null
18+
Boolean, // JSON true or false
19+
Int, // JSON Number
20+
Float, // JSON Number
21+
EnumValue, // JSON String
22+
ID, // JSON String
23+
Scalar, // JSON any type
2424
};
2525
```
2626

doc/subscriptions.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ the subscriptions to those listeners.
1313
Subscriptions are created by calling the `Request::subscribe` method in
1414
[GraphQLService.h](../include/graphqlservice/GraphQLService.h):
1515
```cpp
16-
GRAPHQLSERVICE_EXPORT AwaitableSubscribe subscribe(RequestSubscribeParams params);
16+
GRAPHQLSERVICE_EXPORT [[nodiscard]] AwaitableSubscribe subscribe(RequestSubscribeParams params);
1717
```
1818
1919
You need to fill in a `RequestSubscribeParams` struct with the subscription event
2020
callback, the [parsed](./parsing.md) `query` and any other relevant operation parameters:
2121
```cpp
22-
struct RequestSubscribeParams
22+
struct [[nodiscard]] RequestSubscribeParams
2323
{
2424
// Callback which receives the event data.
2525
SubscriptionCallback callback;
@@ -34,6 +34,9 @@ struct RequestSubscribeParams
3434
3535
// Optional sub-class of RequestState which will be passed to each resolver and field accessor.
3636
std::shared_ptr<RequestState> state;
37+
38+
// Optional override for the default Subscription operation object.
39+
std::shared_ptr<const Object> subscriptionObject {};
3740
};
3841
```
3942

@@ -61,19 +64,22 @@ The `internal::Awaitable<T>` template is described in [awaitable.md](./awaitable
6164
Subscriptions are removed by calling the `Request::unsubscribe` method in
6265
[GraphQLService.h](../include/graphqlservice/GraphQLService.h):
6366
```cpp
64-
GRAPHQLSERVICE_EXPORT AwaitableUnsubscribe unsubscribe(RequestUnsubscribeParams params);
67+
GRAPHQLSERVICE_EXPORT [[nodiscard]] AwaitableUnsubscribe unsubscribe(RequestUnsubscribeParams params);
6568
```
6669
6770
You need to fill in a `RequestUnsubscribeParams` struct with the `SubscriptionKey`
6871
returned by `Request::subscribe` in `AwaitableSubscribe`:
6972
```cpp
70-
struct RequestUnsubscribeParams
73+
struct [[nodiscard]] RequestUnsubscribeParams
7174
{
7275
// Key returned by a previous call to subscribe.
7376
SubscriptionKey key;
7477
7578
// Optional async execution awaitable.
7679
await_async launch;
80+
81+
// Optional override for the default Subscription operation object.
82+
std::shared_ptr<const Object> subscriptionObject {};
7783
};
7884
```
7985

@@ -83,12 +89,12 @@ By default, the resolvers will run on the same thread synchronously.
8389
## `ResolverContext::NotifySubscribe` and `ResolverContext::NotifyUnsubscribe`
8490

8591
If you provide a default instance of the `Subscription` object to the `Request`/
86-
`Operations` constructor, you will get additional callbacks with the
87-
`ResolverContext::NotifySubscribe` and `ResolverContext::NotifyUnsubscribe` values
88-
for the `FieldParams::resolverContext` member. These are passed by the
89-
`subscribe` and `unsubscribe` calls to the default subscription object, and
90-
they provide an opportunity to acquire or release resources that are required
91-
to implement the subscription.
92+
`Operations` constructor, or in the `RequestSubscribeParams`/`RequestUnsubscribeParams`
93+
struct, you will get additional callbacks with the `ResolverContext::NotifySubscribe`
94+
and `ResolverContext::NotifyUnsubscribe` values for the `FieldParams::resolverContext`
95+
member. These are passed by the `subscribe` and `unsubscribe` calls to the default
96+
subscription object, and they provide an opportunity to acquire or release resources
97+
that are required to implement the subscription.
9298

9399
You can provide separate implementations of the `Subscription` object as the
94100
default in the `Operations` constructor and as the payload of a specific
@@ -111,7 +117,7 @@ The `Request::deliver` method determines which subscriptions should receive
111117
an event based on several factors, which makes the `RequestDeliverParams` struct
112118
more complicated:
113119
```cpp
114-
struct RequestDeliverParams
120+
struct [[nodiscard]] RequestDeliverParams
115121
{
116122
// Deliver to subscriptions on this field.
117123
std::string_view field;
@@ -149,7 +155,7 @@ using SubscriptionArguments = std::map<std::string_view, response::Value>;
149155
using SubscriptionArgumentFilterCallback = std::function<bool(response::MapType::const_reference)>;
150156
using SubscriptionDirectiveFilterCallback = std::function<bool(Directives::const_reference)>;
151157

152-
struct SubscriptionFilter
158+
struct [[nodiscard]] SubscriptionFilter
153159
{
154160
// Optional field argument filter, which can either be a set of required arguments, or a
155161
// callback which returns true if the arguments match custom criteria.
@@ -180,6 +186,6 @@ that, there's a public `Request::findOperationDefinition` method which returns
180186
the operation type as a `std::string_view` along with a pointer to the AST node
181187
for the selected operation in the parsed query:
182188
```cpp
183-
GRAPHQLSERVICE_EXPORT std::pair<std::string_view, const peg::ast_node*> findOperationDefinition(
184-
peg::ast& query, std::string_view operationName) const;
189+
GRAPHQLSERVICE_EXPORT [[nodiscard]] std::pair<std::string_view, const peg::ast_node*>
190+
findOperationDefinition(peg::ast& query, std::string_view operationName) const;
185191
```

0 commit comments

Comments
 (0)