@@ -55,7 +55,7 @@ using field_path = std::queue<path_segment>;
55
55
56
56
GRAPHQLSERVICE_EXPORT void addErrorPath (field_path&& path, response::Value& error);
57
57
58
- struct GRAPHQLSERVICE_EXPORT schema_error
58
+ struct schema_error
59
59
{
60
60
std::string message;
61
61
schema_location location;
@@ -65,21 +65,21 @@ struct GRAPHQLSERVICE_EXPORT schema_error
65
65
GRAPHQLSERVICE_EXPORT response::Value buildErrorValues (const std::vector<schema_error>& structuredErrors);
66
66
67
67
// This exception bubbles up 1 or more error messages to the JSON results.
68
- class GRAPHQLSERVICE_EXPORT schema_exception : public std::exception
68
+ class schema_exception : public std ::exception
69
69
{
70
70
public:
71
- explicit schema_exception (std::vector<schema_error>&& structuredErrors);
72
- explicit schema_exception (std::vector<std::string>&& messages);
71
+ GRAPHQLSERVICE_EXPORT explicit schema_exception (std::vector<schema_error>&& structuredErrors);
72
+ GRAPHQLSERVICE_EXPORT explicit schema_exception (std::vector<std::string>&& messages);
73
73
74
74
schema_exception () = delete ;
75
75
76
- const char * what () const noexcept override ;
76
+ GRAPHQLSERVICE_EXPORT const char * what () const noexcept override ;
77
77
78
- const std::vector<schema_error>& getStructuredErrors () const noexcept ;
79
- std::vector<schema_error> getStructuredErrors () noexcept ;
78
+ GRAPHQLSERVICE_EXPORT const std::vector<schema_error>& getStructuredErrors () const noexcept ;
79
+ GRAPHQLSERVICE_EXPORT std::vector<schema_error> getStructuredErrors () noexcept ;
80
80
81
- const response::Value& getErrors () const noexcept ;
82
- response::Value getErrors () noexcept ;
81
+ GRAPHQLSERVICE_EXPORT const response::Value& getErrors () const noexcept ;
82
+ GRAPHQLSERVICE_EXPORT response::Value getErrors () noexcept ;
83
83
84
84
private:
85
85
static std::vector<schema_error> convertMessages (std::vector<std::string>&& messages) noexcept ;
@@ -92,7 +92,7 @@ class GRAPHQLSERVICE_EXPORT schema_exception : public std::exception
92
92
// per-request state that you want to maintain throughout the request (e.g. optimizing or batching
93
93
// backend requests), you can inherit from RequestState and pass it to Request::resolve to correlate the
94
94
// asynchronous/recursive callbacks and accumulate state in it.
95
- struct GRAPHQLSERVICE_EXPORT RequestState : std::enable_shared_from_this<RequestState>
95
+ struct RequestState : std::enable_shared_from_this<RequestState>
96
96
{
97
97
};
98
98
@@ -114,7 +114,7 @@ constexpr std::string_view strSubscription { "subscription"sv };
114
114
}
115
115
116
116
// Pass a common bundle of parameters to all of the generated Object::getField accessors in a SelectionSet
117
- struct GRAPHQLSERVICE_EXPORT SelectionSetParams
117
+ struct SelectionSetParams
118
118
{
119
119
// The lifetime of each of these borrowed references is guaranteed until the future returned
120
120
// by the accessor is resolved or destroyed. They are owned by the OperationData shared pointer.
@@ -136,9 +136,9 @@ struct GRAPHQLSERVICE_EXPORT SelectionSetParams
136
136
};
137
137
138
138
// Pass a common bundle of parameters to all of the generated Object::getField accessors.
139
- struct GRAPHQLSERVICE_EXPORT FieldParams : SelectionSetParams
139
+ struct FieldParams : SelectionSetParams
140
140
{
141
- explicit FieldParams (const SelectionSetParams& selectionSetParams, response::Value&& directives);
141
+ GRAPHQLSERVICE_EXPORT explicit FieldParams (const SelectionSetParams& selectionSetParams, response::Value&& directives);
142
142
143
143
// Each field owns its own field-specific directives. Once the accessor returns it will be destroyed,
144
144
// but you can move it into another instance of response::Value to keep it alive longer.
@@ -174,7 +174,7 @@ class FieldResult
174
174
// Fragments are referenced by name and have a single type condition (except for inline
175
175
// fragments, where the type condition is common but optional). They contain a set of fields
176
176
// (with optional aliases and sub-selections) and potentially references to other fragments.
177
- class GRAPHQLSERVICE_EXPORT Fragment
177
+ class Fragment
178
178
{
179
179
public:
180
180
explicit Fragment (const peg::ast_node& fragmentDefinition, const response::Value& variables);
@@ -197,13 +197,13 @@ using FragmentMap = std::unordered_map<std::string, Fragment>;
197
197
// Resolver functors take a set of arguments encoded as members on a JSON object
198
198
// with an optional selection set for complex types and return a JSON value for
199
199
// a single field.
200
- struct GRAPHQLSERVICE_EXPORT ResolverParams : SelectionSetParams
200
+ struct ResolverParams : SelectionSetParams
201
201
{
202
- explicit ResolverParams (const SelectionSetParams& selectionSetParams, const peg::ast_node& field,
202
+ GRAPHQLSERVICE_EXPORT explicit ResolverParams (const SelectionSetParams& selectionSetParams, const peg::ast_node& field,
203
203
std::string&& fieldName, response::Value&& arguments, response::Value&& fieldDirectives,
204
204
const peg::ast_node* selection, const FragmentMap& fragments, const response::Value& variables);
205
205
206
- schema_location getLocation () const ;
206
+ GRAPHQLSERVICE_EXPORT schema_location getLocation () const ;
207
207
208
208
// These values are different for each resolver.
209
209
const peg::ast_node& field;
@@ -222,7 +222,7 @@ using Resolver = std::function<std::future<response::Value>(ResolverParams&&)>;
222
222
using ResolverMap = std::unordered_map<std::string, Resolver>;
223
223
224
224
// Binary data and opaque strings like IDs are encoded in Base64.
225
- class GRAPHQLSERVICE_EXPORT Base64
225
+ class Base64
226
226
{
227
227
public:
228
228
// Map a single Base64-encoded character to its 6-bit integer value.
@@ -236,7 +236,7 @@ class GRAPHQLSERVICE_EXPORT Base64
236
236
}
237
237
238
238
// Convert a Base64-encoded string to a vector of bytes.
239
- static std::vector<uint8_t > fromBase64 (const char * encoded, size_t count);
239
+ GRAPHQLSERVICE_EXPORT static std::vector<uint8_t > fromBase64 (const char * encoded, size_t count);
240
240
241
241
// Map a single 6-bit integer value to its Base64-encoded character.
242
242
static constexpr char toBase64 (uint8_t i) noexcept
@@ -249,7 +249,7 @@ class GRAPHQLSERVICE_EXPORT Base64
249
249
}
250
250
251
251
// Convert a set of bytes to Base64.
252
- static std::string toBase64 (const std::vector<uint8_t >& bytes);
252
+ GRAPHQLSERVICE_EXPORT static std::string toBase64 (const std::vector<uint8_t >& bytes);
253
253
254
254
private:
255
255
static constexpr char padding = ' =' ;
@@ -430,24 +430,24 @@ using TypeNames = std::unordered_set<std::string>;
430
430
// and @skip directives, and calls through to the resolver functor for each selected field with
431
431
// its arguments. This may be a recursive process for fields which return another complex type,
432
432
// in which case it requires its own selection set.
433
- class GRAPHQLSERVICE_EXPORT Object : public std::enable_shared_from_this<Object>
433
+ class Object : public std ::enable_shared_from_this<Object>
434
434
{
435
435
public:
436
- explicit Object (TypeNames&& typeNames, ResolverMap&& resolvers);
437
- virtual ~Object () = default ;
436
+ GRAPHQLSERVICE_EXPORT explicit Object (TypeNames&& typeNames, ResolverMap&& resolvers);
437
+ GRAPHQLSERVICE_EXPORT virtual ~Object () = default ;
438
438
439
- std::future<response::Value> resolve (const SelectionSetParams& selectionSetParams, const peg::ast_node& selection, const FragmentMap& fragments, const response::Value& variables) const ;
439
+ GRAPHQLSERVICE_EXPORT std::future<response::Value> resolve (const SelectionSetParams& selectionSetParams, const peg::ast_node& selection, const FragmentMap& fragments, const response::Value& variables) const ;
440
440
441
- bool matchesType (const std::string& typeName) const ;
441
+ GRAPHQLSERVICE_EXPORT bool matchesType (const std::string& typeName) const ;
442
442
443
443
protected:
444
444
// These callbacks are optional, you may override either, both, or neither of them. The implementer
445
445
// can use these to to accumulate state for the entire SelectionSet on this object, as well as
446
446
// testing directives which were included at the operation or fragment level. It's up to sub-classes
447
447
// to decide if they want to use const_cast, mutable members, or separate storage in the RequestState
448
448
// to accumulate state. By default these callbacks should treat the Object itself as const.
449
- virtual void beginSelectionSet (const SelectionSetParams& params) const ;
450
- virtual void endSelectionSet (const SelectionSetParams& params) const ;
449
+ GRAPHQLSERVICE_EXPORT virtual void beginSelectionSet (const SelectionSetParams& params) const ;
450
+ GRAPHQLSERVICE_EXPORT virtual void endSelectionSet (const SelectionSetParams& params) const ;
451
451
452
452
std::mutex _resolverMutex {};
453
453
@@ -783,7 +783,7 @@ using TypeMap = std::unordered_map<std::string, std::shared_ptr<Object>>;
783
783
// You can still sub-class RequestState and use that in the state parameter to Request::subscribe
784
784
// to add your own state to the service callbacks that you receive while executing the subscription
785
785
// query.
786
- struct GRAPHQLSERVICE_EXPORT SubscriptionParams
786
+ struct SubscriptionParams
787
787
{
788
788
std::shared_ptr<RequestState> state;
789
789
peg::ast query;
@@ -838,35 +838,35 @@ struct SubscriptionData : std::enable_shared_from_this<SubscriptionData>
838
838
// Request scans the fragment definitions and finds the right operation definition to interpret
839
839
// depending on the operation name (which might be empty for a single-operation document). It
840
840
// also needs the values of the request variables.
841
- class GRAPHQLSERVICE_EXPORT Request : public std::enable_shared_from_this<Request>
841
+ class Request : public std ::enable_shared_from_this<Request>
842
842
{
843
843
protected:
844
- explicit Request (TypeMap&& operationTypes);
845
- virtual ~Request () = default ;
844
+ GRAPHQLSERVICE_EXPORT explicit Request (TypeMap&& operationTypes);
845
+ GRAPHQLSERVICE_EXPORT virtual ~Request () = default ;
846
846
847
847
public:
848
- std::vector<schema_error> validate (peg::ast& query) const ;
848
+ GRAPHQLSERVICE_EXPORT std::vector<schema_error> validate (peg::ast& query) const ;
849
849
850
- std::pair<std::string, const peg::ast_node*> findOperationDefinition (const peg::ast_node& root, const std::string& operationName) const ;
850
+ GRAPHQLSERVICE_EXPORT std::pair<std::string, const peg::ast_node*> findOperationDefinition (const peg::ast_node& root, const std::string& operationName) const ;
851
851
852
- std::future<response::Value> resolve (const std::shared_ptr<RequestState>& state, peg::ast& query, const std::string& operationName, response::Value&& variables) const ;
853
- std::future<response::Value> resolve (std::launch launch, const std::shared_ptr<RequestState>& state, peg::ast& query, const std::string& operationName, response::Value&& variables) const ;
852
+ GRAPHQLSERVICE_EXPORT std::future<response::Value> resolve (const std::shared_ptr<RequestState>& state, peg::ast& query, const std::string& operationName, response::Value&& variables) const ;
853
+ GRAPHQLSERVICE_EXPORT std::future<response::Value> resolve (std::launch launch, const std::shared_ptr<RequestState>& state, peg::ast& query, const std::string& operationName, response::Value&& variables) const ;
854
854
855
- SubscriptionKey subscribe (SubscriptionParams&& params, SubscriptionCallback&& callback);
856
- void unsubscribe (SubscriptionKey key);
855
+ GRAPHQLSERVICE_EXPORT SubscriptionKey subscribe (SubscriptionParams&& params, SubscriptionCallback&& callback);
856
+ GRAPHQLSERVICE_EXPORT void unsubscribe (SubscriptionKey key);
857
857
858
- void deliver (const SubscriptionName& name, const std::shared_ptr<Object>& subscriptionObject) const ;
859
- void deliver (const SubscriptionName& name, const SubscriptionArguments& arguments, const std::shared_ptr<Object>& subscriptionObject) const ;
860
- void deliver (const SubscriptionName& name, const SubscriptionFilterCallback& apply, const std::shared_ptr<Object>& subscriptionObject) const ;
858
+ GRAPHQLSERVICE_EXPORT void deliver (const SubscriptionName& name, const std::shared_ptr<Object>& subscriptionObject) const ;
859
+ GRAPHQLSERVICE_EXPORT void deliver (const SubscriptionName& name, const SubscriptionArguments& arguments, const std::shared_ptr<Object>& subscriptionObject) const ;
860
+ GRAPHQLSERVICE_EXPORT void deliver (const SubscriptionName& name, const SubscriptionFilterCallback& apply, const std::shared_ptr<Object>& subscriptionObject) const ;
861
861
862
- void deliver (std::launch launch, const SubscriptionName& name, const std::shared_ptr<Object>& subscriptionObject) const ;
863
- void deliver (std::launch launch, const SubscriptionName& name, const SubscriptionArguments& arguments, const std::shared_ptr<Object>& subscriptionObject) const ;
864
- void deliver (std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& apply, const std::shared_ptr<Object>& subscriptionObject) const ;
862
+ GRAPHQLSERVICE_EXPORT void deliver (std::launch launch, const SubscriptionName& name, const std::shared_ptr<Object>& subscriptionObject) const ;
863
+ GRAPHQLSERVICE_EXPORT void deliver (std::launch launch, const SubscriptionName& name, const SubscriptionArguments& arguments, const std::shared_ptr<Object>& subscriptionObject) const ;
864
+ GRAPHQLSERVICE_EXPORT void deliver (std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& apply, const std::shared_ptr<Object>& subscriptionObject) const ;
865
865
866
866
[[deprecated(" Use the Request::resolve overload which takes a peg::ast reference instead." )]]
867
- std::future<response::Value> resolve (const std::shared_ptr<RequestState>& state, const peg::ast_node& root, const std::string& operationName, response::Value&& variables) const ;
867
+ GRAPHQLSERVICE_EXPORT std::future<response::Value> resolve (const std::shared_ptr<RequestState>& state, const peg::ast_node& root, const std::string& operationName, response::Value&& variables) const ;
868
868
[[deprecated(" Use the Request::resolve overload which takes a peg::ast reference instead." )]]
869
- std::future<response::Value> resolve (std::launch launch, const std::shared_ptr<RequestState>& state, const peg::ast_node& root, const std::string& operationName, response::Value&& variables) const ;
869
+ GRAPHQLSERVICE_EXPORT std::future<response::Value> resolve (std::launch launch, const std::shared_ptr<RequestState>& state, const peg::ast_node& root, const std::string& operationName, response::Value&& variables) const ;
870
870
871
871
private:
872
872
std::future<response::Value> resolveValidated (std::launch launch, const std::shared_ptr<RequestState>& state, const peg::ast_node& root, const std::string& operationName, response::Value&& variables) const ;
0 commit comments