Skip to content

Commit

Permalink
Fix NPE in checkCapitalizedFields (#4201)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Bonnin <[email protected]>
(cherry picked from commit e28f4a7)
  • Loading branch information
BoD committed Jun 17, 2022
1 parent a1eb70e commit f46450b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ private fun ValidationScope.checkCapitalizedFields(selections: List<GQLSelection
}
}
is GQLInlineFragment -> checkCapitalizedFields(it.selectionSet.selections)
is GQLFragmentSpread -> checkCapitalizedFields(fragmentsByName[it.name]!!.selectionSet.selections)
// it might be that the fragment is defined in an upstream module. In that case, it is validated
// already, no need to check it again
is GQLFragmentSpread -> fragmentsByName[it.name]?.let { fragment -> checkCapitalizedFields(fragment.selectionSet.selections) }
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion tests/multi-module-child/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ dependencies {

apollo {
packageName.set("multimodule.child")
}
flattenModels.set(false)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#
query GetLong2 {
long2: long
... QueryDetails
}
5 changes: 3 additions & 2 deletions tests/multi-module-child/src/test/kotlin/test/TestScalar.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package test

import multimodule.child.GetLong2Query
import multimodule.root.fragment.QueryDetails
import org.junit.Test
import kotlin.test.assertIs

class TestScalar {
@Test
fun testScalar() {
val data = GetLong2Query.Data(0)
val data = GetLong2Query.Data("", 0, QueryDetails(0))
assertIs<Long>(data.long2)
}
}
}

0 comments on commit f46450b

Please sign in to comment.