@@ -1224,20 +1224,23 @@ template <>
1224
1224
{
1225
1225
sourceFile << R"cpp( auto value)cpp" << fieldName
1226
1226
<< R"cpp( = )cpp" << getArgumentAccessType (inputField)
1227
- << R"cpp( ::require(")cpp" << inputField.name
1227
+ << R"cpp( ::require)cpp" << getTypeModifiers (inputField.modifiers )
1228
+ << R"cpp( (")cpp" << inputField.name
1228
1229
<< R"cpp( ", value.as_object());
1229
1230
)cpp" ;
1230
1231
}
1231
1232
else
1232
1233
{
1233
1234
sourceFile << R"cpp( auto pair)cpp" << fieldName
1234
1235
<< R"cpp( = )cpp" << getArgumentAccessType (inputField)
1235
- << R"cpp( ::find(")cpp" << inputField.name
1236
+ << R"cpp( ::find)cpp" << getTypeModifiers (inputField.modifiers )
1237
+ << R"cpp( (")cpp" << inputField.name
1236
1238
<< R"cpp( ", value.as_object());
1237
1239
auto value)cpp" << fieldName << R"cpp( = (pair)cpp" << fieldName << R"cpp( .second
1238
1240
? std::move(pair)cpp" << fieldName << R"cpp( .first)
1239
1241
: )cpp" << getArgumentAccessType (inputField)
1240
- << R"cpp( ::require(")cpp" << inputField.name
1242
+ << R"cpp( ::require)cpp" << getTypeModifiers (inputField.modifiers )
1243
+ << R"cpp( (")cpp" << inputField.name
1241
1244
<< R"cpp( ", defaultValue.as_object()));
1242
1245
)cpp" ;
1243
1246
}
@@ -1447,20 +1450,23 @@ web::json::value )cpp" << objectType.type
1447
1450
{
1448
1451
sourceFile << R"cpp( auto arg)cpp" << argumentName
1449
1452
<< R"cpp( = )cpp" << getArgumentAccessType (argument)
1450
- << R"cpp( ::require(")cpp" << argument.name
1453
+ << R"cpp( ::require)cpp" << getTypeModifiers (argument.modifiers )
1454
+ << R"cpp( (")cpp" << argument.name
1451
1455
<< R"cpp( ", params.arguments);
1452
1456
)cpp" ;
1453
1457
}
1454
1458
else
1455
1459
{
1456
1460
sourceFile << R"cpp( auto pair)cpp" << argumentName
1457
1461
<< R"cpp( = )cpp" << getArgumentAccessType (argument)
1458
- << R"cpp( ::find(")cpp" << argument.name
1462
+ << R"cpp( ::find)cpp" << getTypeModifiers (argument.modifiers )
1463
+ << R"cpp( (")cpp" << argument.name
1459
1464
<< R"cpp( ", params.arguments);
1460
1465
auto arg)cpp" << argumentName << R"cpp( = (pair)cpp" << argumentName << R"cpp( .second
1461
1466
? std::move(pair)cpp" << argumentName << R"cpp( .first)
1462
1467
: )cpp" << getArgumentAccessType (argument)
1463
- << R"cpp( ::require(")cpp" << argument.name
1468
+ << R"cpp( ::require)cpp" << getTypeModifiers (argument.modifiers )
1469
+ << R"cpp( (")cpp" << argument.name
1464
1470
<< R"cpp( ", defaultArguments.as_object()));
1465
1471
)cpp" ;
1466
1472
}
@@ -1491,7 +1497,9 @@ web::json::value )cpp" << objectType.type
1491
1497
1492
1498
sourceFile << R"cpp( );
1493
1499
1494
- return )cpp" << getResultAccessType (outputField) << R"cpp( ::convert(result, std::move(params));
1500
+ return )cpp" << getResultAccessType (outputField)
1501
+ << R"cpp( ::convert)cpp" << getTypeModifiers (outputField.modifiers )
1502
+ << R"cpp( (result, std::move(params));
1495
1503
}
1496
1504
)cpp" ;
1497
1505
}
@@ -1519,7 +1527,7 @@ web::json::value )cpp" << objectType.type
1519
1527
<< R"cpp( ::resolve__type(service::ResolverParams&& params)
1520
1528
{
1521
1529
auto argName = service::ModifiedArgument<std::string>::require("name", params.arguments);
1522
- auto result = service::ModifiedResult<introspection::object::__Type, service::TypeModifier::Nullable>::convert (_schema->LookupType(argName), std::move(params));
1530
+ auto result = service::ModifiedResult<introspection::object::__Type>::convert< service::TypeModifier::Nullable>(_schema->LookupType(argName), std::move(params));
1523
1531
1524
1532
return result;
1525
1533
}
@@ -1990,11 +1998,9 @@ Operations::Operations()cpp";
1990
1998
1991
1999
std::string Generator::getArgumentAccessType (const InputField& argument) const noexcept
1992
2000
{
1993
- size_t templateCount = 0 ;
1994
2001
std::ostringstream argumentType;
1995
2002
1996
2003
argumentType << R"cpp( service::ModifiedArgument<)cpp" ;
1997
- ++templateCount;
1998
2004
1999
2005
switch (argument.fieldType )
2000
2006
{
@@ -2009,35 +2015,16 @@ std::string Generator::getArgumentAccessType(const InputField& argument) const n
2009
2015
break ;
2010
2016
}
2011
2017
2012
- for (auto modifier : argument.modifiers )
2013
- {
2014
- switch (modifier)
2015
- {
2016
- case service::TypeModifier::Nullable:
2017
- argumentType << R"cpp( , service::TypeModifier::Nullable)cpp" ;
2018
- break ;
2019
-
2020
- case service::TypeModifier::List:
2021
- argumentType << R"cpp( , service::TypeModifier::List)cpp" ;
2022
- break ;
2023
- }
2024
- }
2025
-
2026
- for (size_t i = 0 ; i < templateCount; ++i)
2027
- {
2028
- argumentType << R"cpp( >)cpp" ;
2029
- }
2018
+ argumentType << R"cpp( >)cpp" ;
2030
2019
2031
2020
return argumentType.str ();
2032
2021
}
2033
2022
2034
2023
std::string Generator::getResultAccessType (const OutputField& result) const noexcept
2035
2024
{
2036
- size_t templateCount = 0 ;
2037
2025
std::ostringstream resultType;
2038
2026
2039
2027
resultType << R"cpp( service::ModifiedResult<)cpp" ;
2040
- ++templateCount;
2041
2028
2042
2029
switch (result.fieldType )
2043
2030
{
@@ -2057,29 +2044,46 @@ std::string Generator::getResultAccessType(const OutputField& result) const noex
2057
2044
break ;
2058
2045
}
2059
2046
2060
- for (auto modifier : result.modifiers )
2047
+ resultType << R"cpp( >)cpp" ;
2048
+
2049
+ return resultType.str ();
2050
+ }
2051
+
2052
+ std::string Generator::getTypeModifiers (const TypeModifierStack& modifiers) const noexcept
2053
+ {
2054
+ bool firstValue = true ;
2055
+ std::ostringstream typeModifiers;
2056
+
2057
+ for (auto modifier : modifiers)
2061
2058
{
2059
+ if (firstValue)
2060
+ {
2061
+ typeModifiers << R"cpp( <)cpp" ;
2062
+ firstValue = false ;
2063
+ }
2064
+ else
2065
+ {
2066
+ typeModifiers << R"cpp( , )cpp" ;
2067
+ }
2068
+
2062
2069
switch (modifier)
2063
2070
{
2064
2071
case service::TypeModifier::Nullable:
2065
- resultType << R"cpp( , service::TypeModifier::Nullable)cpp" ;
2072
+ typeModifiers << R"cpp( service::TypeModifier::Nullable)cpp" ;
2066
2073
break ;
2067
2074
2068
2075
case service::TypeModifier::List:
2069
- resultType << R"cpp( , service::TypeModifier::List)cpp" ;
2070
- break ;
2071
-
2072
- default :
2076
+ typeModifiers << R"cpp( service::TypeModifier::List)cpp" ;
2073
2077
break ;
2074
2078
}
2075
2079
}
2076
2080
2077
- for ( size_t i = 0 ; i < templateCount; ++i )
2081
+ if (!firstValue )
2078
2082
{
2079
- resultType << R"cpp( >)cpp" ;
2083
+ typeModifiers << R"cpp( >)cpp" ;
2080
2084
}
2081
2085
2082
- return resultType .str ();
2086
+ return typeModifiers .str ();
2083
2087
}
2084
2088
2085
2089
std::string Generator::getIntrospectionType (const std::string& type, const TypeModifierStack& modifiers) const noexcept
0 commit comments