Skip to content

Commit 0e667cf

Browse files
committed
Remove the extra document node from the parse tree
1 parent 8db6a94 commit 0e667cf

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

GraphQLService.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,9 @@ Request::Request(TypeMap&& operationTypes)
381381

382382
rapidjson::Document Request::resolve(const peg::ast_node& root, const std::string& operationName, const rapidjson::Document::ConstObject& variables) const
383383
{
384-
const auto& document = *root.children.front();
385384
FragmentDefinitionVisitor fragmentVisitor;
386385

387-
peg::for_each_child<peg::fragment_definition>(document,
386+
peg::for_each_child<peg::fragment_definition>(root,
388387
[&fragmentVisitor](const peg::ast_node& child)
389388
{
390389
fragmentVisitor.visit(child);
@@ -393,7 +392,7 @@ rapidjson::Document Request::resolve(const peg::ast_node& root, const std::strin
393392
auto fragments = fragmentVisitor.getFragments();
394393
OperationDefinitionVisitor operationVisitor(_operations, operationName, variables, fragments);
395394

396-
peg::for_each_child<peg::operation_definition>(document,
395+
peg::for_each_child<peg::operation_definition>(root,
397396
[&operationVisitor](const peg::ast_node& child)
398397
{
399398
operationVisitor.visit(child);

GraphQLTree.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -552,12 +552,6 @@ struct ast_selector<input_object_type_extension>
552552
{
553553
};
554554

555-
template <>
556-
struct ast_selector<document>
557-
: std::true_type
558-
{
559-
};
560-
561555
std::unique_ptr<ast<std::string>> parseString(std::string&& input)
562556
{
563557
std::unique_ptr<ast<std::string>> result(new ast<std::string> { std::move(input), nullptr });

SchemaGenerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ Generator::Generator()
144144
throw std::logic_error("Unable to parse the introspection schema, but there was no error message from the parser!");
145145
}
146146

147-
for (const auto& child : ast->root->children.front()->children)
147+
for (const auto& child : ast->root->children)
148148
{
149149
visitDefinition(*child);
150150
}
@@ -167,7 +167,7 @@ Generator::Generator(std::string schemaFileName, std::string filenamePrefix, std
167167
throw std::logic_error("Unable to parse the service schema, but there was no error message from the parser!");
168168
}
169169

170-
for (const auto& child : ast->root->children.front()->children)
170+
for (const auto& child : ast->root->children)
171171
{
172172
visitDefinition(*child);
173173
}

0 commit comments

Comments
 (0)