@@ -1277,25 +1277,22 @@ std::future<service::ResolverResult> )cpp"
12771277 sourceFile
12781278 << R"cpp(
12791279std::future<service::ResolverResult> )cpp"
1280- << objectType.cppType
1281- << R"cpp( ::resolve_client(service::ResolverParams&& params)
1280+ << objectType.cppType << R"cpp( ::resolve_client(service::ResolverParams&& params)
12821281{
12831282 return service::ModifiedResult<service::Object>::convert(std::static_pointer_cast<service::Object>(std::make_shared<)cpp"
12841283 << SchemaLoader::getIntrospectionNamespace ()
12851284 << R"cpp( ::Client>(_client)), std::move(params));
12861285}
12871286
12881287std::future<service::ResolverResult> )cpp"
1289- << objectType.cppType
1290- << R"cpp( ::resolve_type(service::ResolverParams&& params)
1288+ << objectType.cppType << R"cpp( ::resolve_type(service::ResolverParams&& params)
12911289{
12921290 auto argName = service::ModifiedArgument<response::StringType>::require("name", params.arguments);
12931291 const auto& baseType = _client->LookupType(argName);
12941292 std::shared_ptr<)cpp"
12951293 << SchemaLoader::getIntrospectionNamespace ()
12961294 << R"cpp( ::object::Type> result { baseType ? std::make_shared<)cpp"
1297- << SchemaLoader::getIntrospectionNamespace ()
1298- << R"cpp( ::Type>(baseType) : nullptr };
1295+ << SchemaLoader::getIntrospectionNamespace () << R"cpp( ::Type>(baseType) : nullptr };
12991296
13001297 return service::ModifiedResult<)cpp"
13011298 << SchemaLoader::getIntrospectionNamespace ()
@@ -1575,37 +1572,61 @@ std::string Generator::getTypeModifiers(const TypeModifierStack& modifiers) cons
15751572
15761573std::shared_ptr<const schema::BaseType> Generator::getIntrospectionType (
15771574 const std::shared_ptr<schema::Schema>& schema, std::string_view type,
1578- TypeModifierStack modifiers, bool nonNull /* = true */ ) noexcept
1575+ const TypeModifierStack& modifiers) noexcept
15791576{
1580- std::shared_ptr<const schema::BaseType> introspectionType;
1577+ std::shared_ptr<const schema::BaseType> introspectionType = schema-> LookupType (type) ;
15811578
1582- if (modifiers.empty ())
1583- {
1584- introspectionType = schema->LookupType (type);
1585- }
1586- else
1579+ if (introspectionType)
15871580 {
1588- const auto modifier = modifiers.front ();
1581+ bool nonNull = true ;
1582+
1583+ for (auto itr = modifiers.crbegin (); itr != modifiers.crend (); ++itr)
1584+ {
1585+ if (nonNull)
1586+ {
1587+ switch (*itr)
1588+ {
1589+ case service::TypeModifier::None:
1590+ case service::TypeModifier::List:
1591+ introspectionType = schema->WrapType (introspection::TypeKind::NON_NULL,
1592+ std::move (introspectionType));
1593+ break ;
1594+
1595+ case service::TypeModifier::Nullable:
1596+ // If the next modifier is Nullable that cancels the non-nullable state.
1597+ nonNull = false ;
1598+ break ;
1599+ }
1600+ }
1601+
1602+ switch (*itr)
1603+ {
1604+ case service::TypeModifier::None:
1605+ {
1606+ nonNull = true ;
1607+ break ;
1608+ }
15891609
1590- modifiers.erase (modifiers.cbegin ());
1591- introspectionType = getIntrospectionType (schema,
1592- type,
1593- std::move (modifiers),
1594- modifier != service::TypeModifier::Nullable);
1610+ case service::TypeModifier::List:
1611+ {
1612+ nonNull = true ;
1613+ introspectionType = schema->WrapType (introspection::TypeKind::LIST,
1614+ std::move (introspectionType));
1615+ break ;
1616+ }
15951617
1596- if (modifier == service::TypeModifier::List && introspectionType)
1618+ case service::TypeModifier::Nullable:
1619+ break ;
1620+ }
1621+ }
1622+
1623+ if (nonNull)
15971624 {
15981625 introspectionType =
1599- schema->WrapType (introspection::TypeKind::LIST , std::move (introspectionType));
1626+ schema->WrapType (introspection::TypeKind::NON_NULL , std::move (introspectionType));
16001627 }
16011628 }
16021629
1603- if (nonNull && introspectionType)
1604- {
1605- introspectionType =
1606- schema->WrapType (introspection::TypeKind::NON_NULL, std::move (introspectionType));
1607- }
1608-
16091630 return introspectionType;
16101631}
16111632
0 commit comments