Repository navigation
fix: prevent duplicate field names through configure - #787
Conversation
|
No actionable comments were generated in the recent review. Summary
Change: Bug fix Merge Risk:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #787 +/- ##
==========================================
+ Coverage 84.46% 84.49% +0.02%
==========================================
Files 151 151
Lines 5112 5113 +1
Branches 893 891 -2
==========================================
+ Hits 4318 4320 +2
+ Misses 492 491 -1
Partials 302 302 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="kgraphql/src/main/kotlin/de/stuebingerb/kgraphql/schema/structure/SchemaCompilation.kt">
<violation number="1" location="kgraphql/src/main/kotlin/de/stuebingerb/kgraphql/schema/structure/SchemaCompilation.kt:454">
P2: The `@NotIntrospected` check in `handleInputType` was removed without explanation. Input classes with that annotation used to fail with "must define one or more fields", and now they compile into normal input types. This change is unrelated to duplicate-name detection, so either restore the check or document the intended behavior in the PR.</violation>
</file>
Architecture diagram
sequenceDiagram
participant Config as Schema Configuration DSL
participant Compiler as SchemaCompilation
participant DuplicateGuard as Duplicate Field Guard
participant Validator as Name Validator
Note over Config,Validator: Schema Validation Flow
Config->>Compiler: configure(inputType/type definitions)
alt Object type compilation
Compiler->>Compiler: Collect memberProperties
Compiler->>DuplicateGuard: addField(field)
DuplicateGuard->>Validator: validateName(field.name)
Validator-->>DuplicateGuard: Name valid
alt Field name already exists
DuplicateGuard->>Compiler: Throw SchemaException (duplicate)
else Unique field name
DuplicateGuard->>Compiler: Return field list
end
else Input type compilation
Compiler->>Compiler: Collect constructor parameters
Compiler->>DuplicateGuard: addInputValue(value)
DuplicateGuard->>Validator: validateName(value.name)
Validator-->>DuplicateGuard: Name valid
alt Field name already exists
DuplicateGuard->>Compiler: Throw SchemaException (duplicate)
else Unique field name
DuplicateGuard->>Compiler: Return input field list
end
else OneOf sealed input compilation
Compiler->>Compiler: Collect sealed subclasses
Compiler->>DuplicateGuard: addInputValue(value)
DuplicateGuard->>Validator: validateName(value.name)
Validator-->>DuplicateGuard: Name valid
alt Field name already exists
DuplicateGuard->>Compiler: Throw SchemaException (duplicate)
else Unique field name
DuplicateGuard->>Compiler: Return input field list
end
end
Compiler->>Compiler: Build Type.Object/Type.InputObject
Compiler->>Config: Return compiled schema
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| ), | ||
| type | ||
| ) | ||
| val fields = mutableListOf<InputValue<*>>() |
There was a problem hiding this comment.
P2: The @NotIntrospected check in handleInputType was removed without explanation. Input classes with that annotation used to fail with "must define one or more fields", and now they compile into normal input types. This change is unrelated to duplicate-name detection, so either restore the check or document the intended behavior in the PR.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At kgraphql/src/main/kotlin/de/stuebingerb/kgraphql/schema/structure/SchemaCompilation.kt, line 454:
<comment>The `@NotIntrospected` check in `handleInputType` was removed without explanation. Input classes with that annotation used to fail with "must define one or more fields", and now they compile into normal input types. This change is unrelated to duplicate-name detection, so either restore the check or document the intended behavior in the PR.</comment>
<file context>
@@ -445,66 +451,60 @@ open class SchemaCompilation(
- ),
- type
- )
+ val fields = mutableListOf<InputValue<*>>()
+ if (kClass.isSealed) {
+ // OneOf input types have one field per allowed sub type
</file context>
There was a problem hiding this comment.
The previous failure was also wrong/unhelpful, and classes annotated with @NotIntrospected were not handled anywhere else during schema compilation. This is a topic for another day.
Resolves #781