Skip to content

Commit dd9dad5

Browse files
committed
Put resolver visitors back in GraphQLService.cpp
1 parent 589b104 commit dd9dad5

File tree

3 files changed

+722
-722
lines changed

3 files changed

+722
-722
lines changed

include/RequestLoader.h

Lines changed: 10 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ namespace graphql::runtime {
1616
class ValueVisitor
1717
{
1818
public:
19-
ValueVisitor(const response::Value& variables);
19+
GRAPHQLSERVICE_EXPORT ValueVisitor(const response::Value& variables);
2020

21-
void visit(const peg::ast_node& value);
21+
GRAPHQLSERVICE_EXPORT void visit(const peg::ast_node& value);
2222

23-
response::Value getValue();
23+
GRAPHQLSERVICE_EXPORT response::Value getValue();
2424

2525
private:
2626
void visitVariable(const peg::ast_node& variable);
@@ -42,129 +42,36 @@ class ValueVisitor
4242
class DirectiveVisitor
4343
{
4444
public:
45-
explicit DirectiveVisitor(const response::Value& variables);
45+
GRAPHQLSERVICE_EXPORT explicit DirectiveVisitor(const response::Value& variables);
4646

47-
void visit(const peg::ast_node& directives);
47+
GRAPHQLSERVICE_EXPORT void visit(const peg::ast_node& directives);
4848

49-
bool shouldSkip() const;
50-
response::Value getDirectives();
49+
GRAPHQLSERVICE_EXPORT bool shouldSkip() const;
50+
GRAPHQLSERVICE_EXPORT response::Value getDirectives();
5151

5252
private:
5353
const response::Value& _variables;
5454

5555
response::Value _directives;
5656
};
5757

58-
// As we recursively expand fragment spreads and inline fragments, we want to accumulate the
59-
// directives at each location and merge them with any directives included in outer fragments to
60-
// build the complete set of directives for nested fragments. Directives with the same name at the
61-
// same location will be overwritten by the innermost fragment.
62-
struct FragmentDirectives
63-
{
64-
response::Value fragmentDefinitionDirectives;
65-
response::Value fragmentSpreadDirectives;
66-
response::Value inlineFragmentDirectives;
67-
};
68-
69-
// SelectionVisitor visits the AST and resolves a field or fragment, unless it's skipped by
70-
// a directive or type condition.
71-
class SelectionVisitor
72-
{
73-
public:
74-
explicit SelectionVisitor(const service::SelectionSetParams& selectionSetParams,
75-
const service::FragmentMap& fragments, const response::Value& variables,
76-
const service::TypeNames& typeNames, const service::ResolverMap& resolvers, size_t count);
77-
78-
void visit(const peg::ast_node& selection);
79-
80-
std::vector<std::pair<std::string_view, std::future<service::ResolverResult>>> getValues();
81-
82-
private:
83-
void visitField(const peg::ast_node& field);
84-
void visitFragmentSpread(const peg::ast_node& fragmentSpread);
85-
void visitInlineFragment(const peg::ast_node& inlineFragment);
86-
87-
const service::ResolverContext _resolverContext;
88-
const std::shared_ptr<service::RequestState>& _state;
89-
const response::Value& _operationDirectives;
90-
const std::optional<std::reference_wrapper<const service::field_path>> _path;
91-
const std::launch _launch;
92-
const service::FragmentMap& _fragments;
93-
const response::Value& _variables;
94-
const service::TypeNames& _typeNames;
95-
const service::ResolverMap& _resolvers;
96-
97-
std::list<FragmentDirectives> _fragmentDirectives;
98-
internal::string_view_set _names;
99-
std::vector<std::pair<std::string_view, std::future<service::ResolverResult>>> _values;
100-
};
101-
10258
// FragmentDefinitionVisitor visits the AST and collects all of the fragment
10359
// definitions in the document.
10460
class FragmentDefinitionVisitor
10561
{
10662
public:
107-
FragmentDefinitionVisitor(const response::Value& variables);
63+
GRAPHQLSERVICE_EXPORT FragmentDefinitionVisitor(const response::Value& variables);
10864

109-
service::FragmentMap getFragments();
65+
GRAPHQLSERVICE_EXPORT service::FragmentMap getFragments();
11066

111-
void visit(const peg::ast_node& fragmentDefinition);
67+
GRAPHQLSERVICE_EXPORT void visit(const peg::ast_node& fragmentDefinition);
11268

11369
private:
11470
const response::Value& _variables;
11571

11672
service::FragmentMap _fragments;
11773
};
11874

119-
// OperationDefinitionVisitor visits the AST and executes the one with the specified
120-
// operation name.
121-
class OperationDefinitionVisitor
122-
{
123-
public:
124-
OperationDefinitionVisitor(service::ResolverContext resolverContext, std::launch launch,
125-
std::shared_ptr<service::RequestState> state, const service::TypeMap& operations, response::Value&& variables,
126-
service::FragmentMap&& fragments);
127-
128-
std::future<service::ResolverResult> getValue();
129-
130-
void visit(std::string_view operationType, const peg::ast_node& operationDefinition);
131-
132-
private:
133-
const service::ResolverContext _resolverContext;
134-
const std::launch _launch;
135-
std::shared_ptr<service::OperationData> _params;
136-
const service::TypeMap& _operations;
137-
std::future<service::ResolverResult> _result;
138-
};
139-
140-
// SubscriptionDefinitionVisitor visits the AST collects the fields referenced in the subscription
141-
// at the point where we create a subscription.
142-
class SubscriptionDefinitionVisitor
143-
{
144-
public:
145-
SubscriptionDefinitionVisitor(service::SubscriptionParams&& params, service::SubscriptionCallback&& callback,
146-
service::FragmentMap&& fragments, const std::shared_ptr<service::Object>& subscriptionObject);
147-
148-
const peg::ast_node& getRoot() const;
149-
std::shared_ptr<service::SubscriptionData> getRegistration();
150-
151-
void visit(const peg::ast_node& operationDefinition);
152-
153-
private:
154-
void visitField(const peg::ast_node& field);
155-
void visitFragmentSpread(const peg::ast_node& fragmentSpread);
156-
void visitInlineFragment(const peg::ast_node& inlineFragment);
157-
158-
service::SubscriptionParams _params;
159-
service::SubscriptionCallback _callback;
160-
service::FragmentMap _fragments;
161-
const std::shared_ptr<service::Object>& _subscriptionObject;
162-
service::SubscriptionName _field;
163-
response::Value _arguments;
164-
response::Value _fieldDirectives;
165-
std::shared_ptr<service::SubscriptionData> _result;
166-
};
167-
16875
} /* namespace graphql::runtime */
16976

17077
#endif // REQUESTLOADER_H

0 commit comments

Comments
 (0)