Skip to content

Commit 0062814

Browse files
committed
Include fewer headers and rely on forward declaration in ...Schema.h
1 parent 6ae3790 commit 0062814

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

samples/learn/schema/StarWarsSchema.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
// WARNING! Do not edit this file manually, your changes will be overwritten.
55

6-
#include "StarWarsObjects.h"
6+
#include "QueryObject.h"
7+
#include "MutationObject.h"
78

89
#include "graphqlservice/introspection/Introspection.h"
910

samples/today/separate/TodaySchema.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
// WARNING! Do not edit this file manually, your changes will be overwritten.
55

6-
#include "TodayObjects.h"
6+
#include "QueryObject.h"
7+
#include "MutationObject.h"
8+
#include "SubscriptionObject.h"
79

810
#include "graphqlservice/introspection/Introspection.h"
911

samples/today/separate_nointrospection/TodaySchema.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
// WARNING! Do not edit this file manually, your changes will be overwritten.
55

6-
#include "TodayObjects.h"
6+
#include "QueryObject.h"
7+
#include "MutationObject.h"
8+
#include "SubscriptionObject.h"
79

810
#include "graphqlservice/introspection/Introspection.h"
911

src/SchemaGenerator.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,24 @@ bool Generator::outputSource() const noexcept
575575

576576
if (!_loader.isIntrospection())
577577
{
578-
sourceFile << R"cpp(#include ")cpp" << fs::path(_objectHeaderPath).filename().string()
579-
<< R"cpp("
578+
if (!_options.separateFiles)
579+
{
580+
581+
sourceFile << R"cpp(#include ")cpp" << fs::path(_headerPath).filename().string()
582+
<< R"cpp("
580583
581584
)cpp";
585+
}
586+
else
587+
{
588+
for (const auto& operation : _loader.getOperationTypes())
589+
{
590+
sourceFile << R"cpp(#include ")cpp" << operation.cppType << R"cpp(Object.h"
591+
)cpp";
592+
}
593+
594+
sourceFile << std::endl;
595+
}
582596
}
583597

584598
sourceFile << R"cpp(#include "graphqlservice/introspection/Introspection.h"

0 commit comments

Comments
 (0)