@@ -764,7 +764,10 @@ void Generator::visitObjectTypeDefinition(const peg::ast_node& objectTypeDefinit
764
764
peg::on_first_child<peg::description>(objectTypeDefinition,
765
765
[&description](const peg::ast_node& child)
766
766
{
767
- description = child.children .front ()->unescaped ;
767
+ if (!child.children .empty ())
768
+ {
769
+ description = child.children .front ()->unescaped ;
770
+ }
768
771
});
769
772
770
773
_schemaTypes[name] = SchemaType::Object;
@@ -828,7 +831,10 @@ void Generator::visitInterfaceTypeDefinition(const peg::ast_node& interfaceTypeD
828
831
peg::on_first_child<peg::description>(interfaceTypeDefinition,
829
832
[&description](const peg::ast_node& child)
830
833
{
831
- description = child.children .front ()->unescaped ;
834
+ if (!child.children .empty ())
835
+ {
836
+ description = child.children .front ()->unescaped ;
837
+ }
832
838
});
833
839
834
840
_schemaTypes[name] = SchemaType::Interface;
@@ -886,7 +892,10 @@ void Generator::visitInputObjectTypeDefinition(const peg::ast_node& inputObjectT
886
892
peg::on_first_child<peg::description>(inputObjectTypeDefinition,
887
893
[&description](const peg::ast_node& child)
888
894
{
889
- description = child.children .front ()->unescaped ;
895
+ if (!child.children .empty ())
896
+ {
897
+ description = child.children .front ()->unescaped ;
898
+ }
890
899
});
891
900
892
901
_schemaTypes[name] = SchemaType::Input;
@@ -944,7 +953,10 @@ void Generator::visitEnumTypeDefinition(const peg::ast_node& enumTypeDefinition)
944
953
peg::on_first_child<peg::description>(enumTypeDefinition,
945
954
[&description](const peg::ast_node& child)
946
955
{
947
- description = child.children .front ()->unescaped ;
956
+ if (!child.children .empty ())
957
+ {
958
+ description = child.children .front ()->unescaped ;
959
+ }
948
960
});
949
961
950
962
_schemaTypes[name] = SchemaType::Enum;
@@ -987,9 +999,12 @@ void Generator::visitEnumTypeExtension(const peg::ast_node& enumTypeExtension)
987
999
});
988
1000
989
1001
peg::on_first_child<peg::description>(child,
990
- [&value](const peg::ast_node& enumValue )
1002
+ [&value](const peg::ast_node& description )
991
1003
{
992
- value.description = enumValue.children .front ()->unescaped ;
1004
+ if (!description.children .empty ())
1005
+ {
1006
+ value.description = description.children .front ()->unescaped ;
1007
+ }
993
1008
});
994
1009
995
1010
peg::on_first_child<peg::directives>(child,
@@ -1058,7 +1073,10 @@ void Generator::visitScalarTypeDefinition(const peg::ast_node& scalarTypeDefinit
1058
1073
peg::on_first_child<peg::description>(scalarTypeDefinition,
1059
1074
[&description](const peg::ast_node& child)
1060
1075
{
1061
- description = child.children .front ()->unescaped ;
1076
+ if (!child.children .empty ())
1077
+ {
1078
+ description = child.children .front ()->unescaped ;
1079
+ }
1062
1080
});
1063
1081
1064
1082
_schemaTypes[name] = SchemaType::Scalar;
@@ -1081,7 +1099,10 @@ void Generator::visitUnionTypeDefinition(const peg::ast_node& unionTypeDefinitio
1081
1099
peg::on_first_child<peg::description>(unionTypeDefinition,
1082
1100
[&description](const peg::ast_node& child)
1083
1101
{
1084
- description = child.children .front ()->unescaped ;
1102
+ if (!child.children .empty ())
1103
+ {
1104
+ description = child.children .front ()->unescaped ;
1105
+ }
1085
1106
});
1086
1107
1087
1108
_schemaTypes[name] = SchemaType::Union;
@@ -1132,7 +1153,10 @@ void Generator::visitDirectiveDefinition(const peg::ast_node& directiveDefinitio
1132
1153
peg::on_first_child<peg::description>(directiveDefinition,
1133
1154
[&directive](const peg::ast_node& child)
1134
1155
{
1135
- directive.description = child.children .front ()->unescaped ;
1156
+ if (!child.children .empty ())
1157
+ {
1158
+ directive.description = child.children .front ()->unescaped ;
1159
+ }
1136
1160
});
1137
1161
1138
1162
peg::for_each_child<peg::directive_location>(directiveDefinition,
@@ -1206,7 +1230,8 @@ OutputFieldList Generator::getOutputFields(const std::vector<std::unique_ptr<peg
1206
1230
{
1207
1231
fieldType.visit (*child);
1208
1232
}
1209
- else if (child->is_type <peg::description>())
1233
+ else if (child->is_type <peg::description>()
1234
+ && !child->children .empty ())
1210
1235
{
1211
1236
field.description = child->children .front ()->unescaped ;
1212
1237
}
@@ -1300,7 +1325,8 @@ InputFieldList Generator::getInputFields(const std::vector<std::unique_ptr<peg::
1300
1325
1301
1326
defaultValueLocation = { position.line , position.column };
1302
1327
}
1303
- else if (child->is_type <peg::description>())
1328
+ else if (child->is_type <peg::description>()
1329
+ && !child->children .empty ())
1304
1330
{
1305
1331
field.description = child->children .front ()->unescaped ;
1306
1332
}
0 commit comments