Skip to content

Commit f0dde15

Browse files
committed
Move visitors back to GraphQLService because of variables
1 parent d6b6e97 commit f0dde15

File tree

6 files changed

+344
-328
lines changed

6 files changed

+344
-328
lines changed

include/ClientGenerator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define CLIENTGENERATOR_H
88

99
#include "SchemaLoader.h"
10+
#include "RequestLoader.h"
1011

1112
#include "graphqlservice/GraphQLSchema.h"
1213

include/RequestLoader.h

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -9,69 +9,19 @@
99
#include "graphqlservice/GraphQLParse.h"
1010
#include "graphqlservice/GraphQLService.h"
1111

12-
namespace graphql::runtime {
12+
namespace graphql::generator {
1313

14-
// ValueVisitor visits the AST and builds a response::Value representation of any value
15-
// hardcoded or referencing a variable in an operation.
16-
class ValueVisitor
14+
class RequestLoader
1715
{
1816
public:
19-
GRAPHQLSERVICE_EXPORT ValueVisitor(const response::Value& variables);
17+
explicit RequestLoader();
2018

21-
GRAPHQLSERVICE_EXPORT void visit(const peg::ast_node& value);
22-
23-
GRAPHQLSERVICE_EXPORT response::Value getValue();
24-
25-
private:
26-
void visitVariable(const peg::ast_node& variable);
27-
void visitIntValue(const peg::ast_node& intValue);
28-
void visitFloatValue(const peg::ast_node& floatValue);
29-
void visitStringValue(const peg::ast_node& stringValue);
30-
void visitBooleanValue(const peg::ast_node& booleanValue);
31-
void visitNullValue(const peg::ast_node& nullValue);
32-
void visitEnumValue(const peg::ast_node& enumValue);
33-
void visitListValue(const peg::ast_node& listValue);
34-
void visitObjectValue(const peg::ast_node& objectValue);
35-
36-
const response::Value& _variables;
37-
response::Value _value;
38-
};
39-
40-
// DirectiveVisitor visits the AST and builds a 2-level map of directive names to argument
41-
// name/value pairs.
42-
class DirectiveVisitor
43-
{
44-
public:
45-
GRAPHQLSERVICE_EXPORT explicit DirectiveVisitor(const response::Value& variables);
46-
47-
GRAPHQLSERVICE_EXPORT void visit(const peg::ast_node& directives);
48-
49-
GRAPHQLSERVICE_EXPORT bool shouldSkip() const;
50-
GRAPHQLSERVICE_EXPORT response::Value getDirectives();
51-
52-
private:
53-
const response::Value& _variables;
54-
55-
response::Value _directives;
56-
};
57-
58-
// FragmentDefinitionVisitor visits the AST and collects all of the fragment
59-
// definitions in the document.
60-
class FragmentDefinitionVisitor
61-
{
62-
public:
63-
GRAPHQLSERVICE_EXPORT FragmentDefinitionVisitor(const response::Value& variables);
64-
65-
GRAPHQLSERVICE_EXPORT service::FragmentMap getFragments();
66-
67-
GRAPHQLSERVICE_EXPORT void visit(const peg::ast_node& fragmentDefinition);
19+
void visit(const peg::ast& request, std::string_view operationName);
6820

6921
private:
70-
const response::Value& _variables;
7122

72-
service::FragmentMap _fragments;
7323
};
7424

75-
} /* namespace graphql::runtime */
25+
} /* namespace graphql::generator */
7626

7727
#endif // REQUESTLOADER_H

include/SchemaLoader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ struct SchemaOptions
230230
class SchemaLoader
231231
{
232232
public:
233-
// Initialize the generator with the introspection schema or a custom GraphQL schema.
233+
// Initialize the loader with the introspection schema or a custom GraphQL schema.
234234
explicit SchemaLoader(std::optional<SchemaOptions>&& customSchema);
235235

236236
bool isIntrospection() const noexcept;

src/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ endif()
154154

155155
# clientgen
156156
if(GRAPHQL_BUILD_CLIENTGEN)
157-
add_executable(clientgen ClientGenerator.cpp)
157+
add_executable(clientgen
158+
ClientGenerator.cpp
159+
RequestLoader.cpp)
158160
add_executable(cppgraphqlgen::clientgen ALIAS clientgen)
159161
target_link_libraries(clientgen PRIVATE generator_util)
160162
add_bigobj_flag(clientgen)
@@ -292,7 +294,6 @@ endif()
292294
add_library(graphqlservice
293295
GraphQLService.cpp
294296
GraphQLSchema.cpp
295-
RequestLoader.cpp
296297
Validation.cpp)
297298
add_library(cppgraphqlgen::graphqlservice ALIAS graphqlservice)
298299
target_link_libraries(graphqlservice PUBLIC

0 commit comments

Comments
 (0)