Skip to content

Commit 997abc7

Browse files
Rafał Hibnerclaude
andcommitted
fix: fixupOutputFieldList skips argument type fixup for builtin return types
Move fixupInputFieldList(entry.arguments) before the early continue for builtin return types so that input object arguments are always resolved regardless of the output field's return type. Without this fix, any field returning a builtin type (String, Int, etc.) that takes a nullable input object argument generates std::optional<T> instead of std::unique_ptr<T> in the concept, causing a compile error. Non-null input object arguments with an empty default ({}) crash schemagen with std::out_of_range in shouldMoveInputField. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7e02f33 commit 997abc7

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎src/SchemaLoader.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ void SchemaLoader::fixupOutputFieldList(OutputFieldList& fields,
254254
entry.accessor = *accessor;
255255
}
256256

257+
fixupInputFieldList(entry.arguments);
258+
257259
if (s_builtinTypes.find(entry.type) != s_builtinTypes.cend())
258260
{
259261
continue;
@@ -311,8 +313,6 @@ void SchemaLoader::fixupOutputFieldList(OutputFieldList& fields,
311313
throw std::runtime_error(error);
312314
}
313315
}
314-
315-
fixupInputFieldList(entry.arguments);
316316
}
317317
}
318318

‎test/SchemaLoaderTests.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ TEST(SchemaGenCase, NullableInputArgOnBuiltinReturnField)
8383
EXPECT_EQ(headerContent.find("std::optional<TestInput>"), std::string::npos)
8484
<< "concept should NOT use std::optional<TestInput> for nullable input object argument";
8585

86-
// Also check the source file for consistent usage.
86+
// Also check the source file uses the correct ModifiedArgument with Nullable.
8787
const auto sourceContent = readFile(outDir.path() / "QueryObject.cpp");
8888
ASSERT_FALSE(sourceContent.empty()) << "QueryObject.cpp should be generated";
8989

90-
EXPECT_NE(sourceContent.find("unique_ptr<TestInput>"), std::string::npos)
91-
<< "resolver should use unique_ptr<TestInput>";
90+
EXPECT_NE(sourceContent.find("ModifiedArgument<test::TestInput>"), std::string::npos)
91+
<< "resolver should use ModifiedArgument<test::TestInput>";
9292
}
9393

9494
// Regression test: run schemagen on a schema where a builtin-returning field

0 commit comments

Comments
 (0)