Skip to content

Commit cd78984

Browse files
authored
Merge pull request #107 from wravery/master
Fix issues #105 and #106
2 parents b7829aa + 250fd87 commit cd78984

File tree

3 files changed

+46
-19
lines changed

3 files changed

+46
-19
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set(CMAKE_CXX_STANDARD 17)
99
set(GRAPHQL_INSTALL_INCLUDE_DIR include CACHE PATH "Header file install directory")
1010
set(GRAPHQL_INSTALL_TOOLS_DIR bin CACHE PATH "schemagen install directory")
1111
set(GRAPHQL_INSTALL_CMAKE_DIR lib/cmake CACHE PATH "CMake config files install directory")
12+
set(GRAPHQL_INSTALL_CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES} CACHE STRING "Configurations which perform a full install")
1213

1314
option(BUILD_SHARED_LIBS "Build shared libraries instead of static libs" OFF)
1415

src/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ if(GRAPHQL_BUILD_SCHEMAGEN)
5959

6060
install(TARGETS schemagen
6161
EXPORT cppgraphqlgen-targets
62-
RUNTIME DESTINATION ${GRAPHQL_INSTALL_TOOLS_DIR}/${PROJECT_NAME}
63-
CONFIGURATIONS Release)
62+
CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS}
63+
RUNTIME DESTINATION ${GRAPHQL_INSTALL_TOOLS_DIR}/${PROJECT_NAME})
6464
endif()
6565

6666
# introspection
@@ -111,8 +111,8 @@ target_link_libraries(graphqlservice PUBLIC
111111
graphqlpeg
112112
Threads::Threads)
113113
target_link_libraries(graphqlservice PUBLIC graphqlresponse)
114-
target_include_directories(graphqlservice SYSTEM PRIVATE
115-
${CMAKE_CURRENT_BINARY_DIR}/../include)
114+
target_include_directories(graphqlservice PUBLIC
115+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include>)
116116

117117
if(WIN32 AND BUILD_SHARED_LIBS)
118118
target_compile_definitions(graphqlservice
@@ -155,8 +155,8 @@ if(BUILD_GRAPHQLJSON)
155155
ARCHIVE DESTINATION lib
156156
LIBRARY DESTINATION lib)
157157
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/JSONResponse.h
158-
DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice
159-
CONFIGURATIONS Release)
158+
CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS}
159+
DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice)
160160
else()
161161
set(GRAPHQL_BUILD_TESTS OFF CACHE BOOL "GRAPHQL_BUILD_TESTS depends on BUILD_GRAPHQLJSON" FORCE)
162162
endif()
@@ -178,8 +178,8 @@ install(FILES
178178
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/GraphQLTree.h
179179
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/Introspection.h
180180
${CMAKE_CURRENT_BINARY_DIR}/../include/graphqlservice/IntrospectionSchema.h
181-
DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice
182-
CONFIGURATIONS Release)
181+
CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS}
182+
DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice)
183183

184184
install(EXPORT cppgraphqlgen-targets
185185
NAMESPACE cppgraphqlgen::

src/SchemaGenerator.cpp

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,10 @@ void Generator::visitObjectTypeDefinition(const peg::ast_node& objectTypeDefinit
764764
peg::on_first_child<peg::description>(objectTypeDefinition,
765765
[&description](const peg::ast_node& child)
766766
{
767-
description = child.children.front()->unescaped;
767+
if (!child.children.empty())
768+
{
769+
description = child.children.front()->unescaped;
770+
}
768771
});
769772

770773
_schemaTypes[name] = SchemaType::Object;
@@ -828,7 +831,10 @@ void Generator::visitInterfaceTypeDefinition(const peg::ast_node& interfaceTypeD
828831
peg::on_first_child<peg::description>(interfaceTypeDefinition,
829832
[&description](const peg::ast_node& child)
830833
{
831-
description = child.children.front()->unescaped;
834+
if (!child.children.empty())
835+
{
836+
description = child.children.front()->unescaped;
837+
}
832838
});
833839

834840
_schemaTypes[name] = SchemaType::Interface;
@@ -886,7 +892,10 @@ void Generator::visitInputObjectTypeDefinition(const peg::ast_node& inputObjectT
886892
peg::on_first_child<peg::description>(inputObjectTypeDefinition,
887893
[&description](const peg::ast_node& child)
888894
{
889-
description = child.children.front()->unescaped;
895+
if (!child.children.empty())
896+
{
897+
description = child.children.front()->unescaped;
898+
}
890899
});
891900

892901
_schemaTypes[name] = SchemaType::Input;
@@ -944,7 +953,10 @@ void Generator::visitEnumTypeDefinition(const peg::ast_node& enumTypeDefinition)
944953
peg::on_first_child<peg::description>(enumTypeDefinition,
945954
[&description](const peg::ast_node& child)
946955
{
947-
description = child.children.front()->unescaped;
956+
if (!child.children.empty())
957+
{
958+
description = child.children.front()->unescaped;
959+
}
948960
});
949961

950962
_schemaTypes[name] = SchemaType::Enum;
@@ -987,9 +999,12 @@ void Generator::visitEnumTypeExtension(const peg::ast_node& enumTypeExtension)
987999
});
9881000

9891001
peg::on_first_child<peg::description>(child,
990-
[&value](const peg::ast_node& enumValue)
1002+
[&value](const peg::ast_node& description)
9911003
{
992-
value.description = enumValue.children.front()->unescaped;
1004+
if (!description.children.empty())
1005+
{
1006+
value.description = description.children.front()->unescaped;
1007+
}
9931008
});
9941009

9951010
peg::on_first_child<peg::directives>(child,
@@ -1058,7 +1073,10 @@ void Generator::visitScalarTypeDefinition(const peg::ast_node& scalarTypeDefinit
10581073
peg::on_first_child<peg::description>(scalarTypeDefinition,
10591074
[&description](const peg::ast_node& child)
10601075
{
1061-
description = child.children.front()->unescaped;
1076+
if (!child.children.empty())
1077+
{
1078+
description = child.children.front()->unescaped;
1079+
}
10621080
});
10631081

10641082
_schemaTypes[name] = SchemaType::Scalar;
@@ -1081,7 +1099,10 @@ void Generator::visitUnionTypeDefinition(const peg::ast_node& unionTypeDefinitio
10811099
peg::on_first_child<peg::description>(unionTypeDefinition,
10821100
[&description](const peg::ast_node& child)
10831101
{
1084-
description = child.children.front()->unescaped;
1102+
if (!child.children.empty())
1103+
{
1104+
description = child.children.front()->unescaped;
1105+
}
10851106
});
10861107

10871108
_schemaTypes[name] = SchemaType::Union;
@@ -1132,7 +1153,10 @@ void Generator::visitDirectiveDefinition(const peg::ast_node& directiveDefinitio
11321153
peg::on_first_child<peg::description>(directiveDefinition,
11331154
[&directive](const peg::ast_node& child)
11341155
{
1135-
directive.description = child.children.front()->unescaped;
1156+
if (!child.children.empty())
1157+
{
1158+
directive.description = child.children.front()->unescaped;
1159+
}
11361160
});
11371161

11381162
peg::for_each_child<peg::directive_location>(directiveDefinition,
@@ -1206,7 +1230,8 @@ OutputFieldList Generator::getOutputFields(const std::vector<std::unique_ptr<peg
12061230
{
12071231
fieldType.visit(*child);
12081232
}
1209-
else if (child->is_type<peg::description>())
1233+
else if (child->is_type<peg::description>()
1234+
&& !child->children.empty())
12101235
{
12111236
field.description = child->children.front()->unescaped;
12121237
}
@@ -1300,7 +1325,8 @@ InputFieldList Generator::getInputFields(const std::vector<std::unique_ptr<peg::
13001325

13011326
defaultValueLocation = { position.line, position.column };
13021327
}
1303-
else if (child->is_type<peg::description>())
1328+
else if (child->is_type<peg::description>()
1329+
&& !child->children.empty())
13041330
{
13051331
field.description = child->children.front()->unescaped;
13061332
}

0 commit comments

Comments
 (0)