Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compiler] Fix detection of used arguments #5837

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ internal class InterfaceBuilder(

override fun prepare() {
context.resolver.registerSchemaType(iface.name, ClassName.get(packageName, simpleName))
for (fieldDefinition in iface.fieldDefinitions) {
fieldDefinition.argumentDefinitions.forEach { argumentDefinition ->
context.resolver.registerArgumentDefinition(argumentDefinition.id, ClassName.get(packageName, simpleName))
}
}
}

override fun build(): CodegenJavaFile {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ internal class InterfaceBuilder(
context.resolver.registerSchemaType(iface.name, ClassName(packageName, simpleName))
context.resolver.registerMapType(iface.name, ClassName(packageName, mapName))
context.resolver.registerBuilderType(iface.name, ClassName(packageName, builderName))
for (fieldDefinition in iface.fieldDefinitions) {
fieldDefinition.argumentDefinitions.forEach { argumentDefinition ->
context.resolver.registerArgumentDefinition(argumentDefinition.id, ClassName(packageName, simpleName))
}
}
}

override fun build(): CgFile {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,10 @@ internal class IrOperationsBuilder(
usedCoordinates.putType(first.type.rawType().name)

// Track argument usage
for (usedArgument in first.usedArguments) {
usedCoordinates.putArgument(first.parentType, first.name, usedArgument)
fields.map { it.parentType }.distinct().forEach { parentType ->
for (usedArgument in first.usedArguments) {
usedCoordinates.putArgument(parentType, first.name, usedArgument)
}
}

val irType = first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// If you updated the codegen and test fixtures, you should commit this file too.

Test: Total LOC:
aggregate-all 202649
aggregate-kotlin-responseBased 65139
aggregate-kotlin-operationBased 41775
aggregate-all 204924
aggregate-kotlin-responseBased 65822
aggregate-kotlin-operationBased 42426
aggregate-kotlin-compat 0
aggregate-java-operationBased 95735
aggregate-java-operationBased 96676

java-operationBased-fragments_with_defer_and_include_directives 5600
kotlin-operationBased-fragments_with_defer_and_include_directives 3488
Expand Down Expand Up @@ -60,7 +60,7 @@ java-operationBased-root_query_inline_fragment
kotlin-operationBased-fragment_spread_with_include_directive 1121
kotlin-operationBased-unique_type_name 1109
kotlin-responseBased-fragments_with_type_condition 1102
kotlin-responseBased-nested_conditional_inline 1082
kotlin-responseBased-nested_conditional_inline 1085
java-operationBased-java_primitive_types 1077
kotlin-responseBased-multiple_fragments 1074
kotlin-responseBased-named_fragment_with_variables 1067
Expand All @@ -80,6 +80,7 @@ java-operationBased-deprecated_merged_field
kotlin-operationBased-nested_conditional_inline 948
java-operationBased-input_object_oneof 943
java-operationBased-hero_details 941
java-operationBased-used_arguments 941
java-operationBased-not_all_combinations_are_needed 938
java-operationBased-simple_inline_fragment 919
kotlin-responseBased-mutation_create_review_semantic_naming 918
Expand Down Expand Up @@ -127,6 +128,7 @@ kotlin-responseBased-input_object_variable_and_argument_with_generated_methods
java-operationBased-monomorphic 689
kotlin-operationBased-operationbased2_ex8 685
java-operationBased-interface_always_nested 683
kotlin-responseBased-used_arguments 680
kotlin-responseBased-union_fragment 678
kotlin-responseBased-java_android_annotations 674
kotlin-responseBased-java_apollo_optionals 674
Expand All @@ -143,6 +145,7 @@ java-operationBased-deprecation
kotlin-responseBased-fragment_with_multiple_fieldsets 659
kotlin-responseBased-test_inline 657
kotlin-responseBased-named_fragment_without_implementation 651
kotlin-operationBased-used_arguments 651
kotlin-operationBased-union_fragment 650
kotlin-operationBased-decapitalized_fields 647
kotlin-responseBased-hero_details 647
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
fragment ADetails on A {
field(arg: 42)
}

query GetA {
a {
... on B {
field(arg: 42)
}
... on C {
field(arg: 42)
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading