Marco Pierucci
05/03/2024, 12:31 PMoverride fun resolveTypename(context: FakeResolverContext): String {
val rawType = context.mergedField.type.rawType()
// XXX: Cache this computation
val possibleTypes = possibleTypes(allTypes, rawType)
val index = context.id.hashCode().mod(possibleTypes.size)
return possibleTypes[index].name
}
Is throwing java.lang.ArithmeticException: / by zero
for some data builders im trying to use in tests.Marco Pierucci
05/03/2024, 12:31 PMmbonnin
05/03/2024, 1:02 PMmodulo
throwing?mbonnin
05/03/2024, 1:05 PMrawType
there? Is it a composite type (object/interface/union)?Marco Pierucci
05/03/2024, 1:06 PMMarco Pierucci
05/03/2024, 1:08 PMMarco Pierucci
05/03/2024, 1:09 PMMarco Pierucci
05/03/2024, 1:09 PMworkOrder = WorkOrderInfoImpl.Data(KrakenFieldFakeResolver()) {
buildCustomWorkOrderType {
id = "J_3443"
customer = buildGBRCustomerType {
name = "Jhon"
phone = "442355"
extension = "+54"
psrData = listOf(
buildPSRCustomerType {
summary = "summary"
internalCode = "internalCode"
gasPsrCode = "gasPsrCode"
electricityPsrCode = "electricityPsrCode"
expiryDate = LocalDate.parse("2021-10-10")
},
)
}
mbonnin
05/03/2024, 1:11 PMThe type is CustomerType which is a framgentI’m guessing
CustomerType
is more of an interface?mbonnin
05/03/2024, 1:11 PMGBRCustomerType
a concrete type?mbonnin
05/03/2024, 1:11 PMtype GBRCustomerType implements CustomerType
?Marco Pierucci
05/03/2024, 1:19 PMMarco Pierucci
05/03/2024, 1:23 PMfragment customerType on CustomerType {
id
accountNumber
name
phone
extension
email
familyName
givenName
... on GBRCustomerType {
psrData {
summary
internalCode
gasPsrCode
electricityPsrCode
expiryDate
}
}
}
Marco Pierucci
05/03/2024, 1:23 PMmbonnin
05/03/2024, 1:32 PMpossibleTypes(allTypes, "CustomerType")
returns empty 🤔mbonnin
05/03/2024, 1:36 PM__Schema.possibleTypes(CustomerType.type)
return?Marco Pierucci
05/03/2024, 1:37 PMMarco Pierucci
05/03/2024, 1:39 PMmbonnin
05/03/2024, 1:40 PMmbonnin
05/03/2024, 1:40 PM__Schema.all
contain GBRCustomerType
?mbonnin
05/03/2024, 1:41 PMMarco Pierucci
05/03/2024, 1:42 PMMarco Pierucci
05/03/2024, 1:42 PMMarco Pierucci
05/03/2024, 1:42 PMmbonnin
05/03/2024, 1:43 PMapolloMetadata()
dependency to reuse the network module schemambonnin
05/03/2024, 1:44 PMMarco Pierucci
05/03/2024, 1:44 PMmbonnin
05/03/2024, 1:45 PM__Schema
class in your app module?mbonnin
05/03/2024, 1:45 PM__Schema
class in your whole repositoryMarco Pierucci
05/03/2024, 1:46 PMapolloMetadata(project(":network"))
Marco Pierucci
05/03/2024, 1:46 PMMarco Pierucci
05/03/2024, 1:47 PMall
are from that moduleMarco Pierucci
05/03/2024, 1:48 PMalwaysGenerateTypesMatching = listOf("APIErrorCode")
Marco Pierucci
05/03/2024, 1:48 PMMarco Pierucci
05/03/2024, 1:48 PMMarco Pierucci
05/03/2024, 1:48 PMmbonnin
05/03/2024, 1:50 PMmbonnin
05/03/2024, 1:50 PMmbonnin
05/03/2024, 1:51 PMalwaysGenerateTypesMatching.set(listOf(".*"))
which will always work at the expense of generating everythingmbonnin
05/03/2024, 1:53 PMmbonnin
05/03/2024, 1:54 PMdependencies {
apolloUsedCoordinates(project(":app"))
}
?Marco Pierucci
05/03/2024, 1:58 PMMarco Pierucci
05/03/2024, 2:00 PMmbonnin
05/03/2024, 2:00 PMMarco Pierucci
05/03/2024, 2:05 PMmbonnin
05/03/2024, 2:07 PMapolloSchema
in your app module
// But also from the schema so as not to create a circular dependency
apolloSchema(project(":schema"))
mbonnin
05/03/2024, 2:08 PMMarco Pierucci
05/03/2024, 2:12 PMMarco Pierucci
05/03/2024, 2:12 PMMarco Pierucci
05/03/2024, 2:13 PMMarco Pierucci
05/03/2024, 2:13 PMmbonnin
05/03/2024, 2:17 PMschema.graphqls
using apolloSchema()
• app parses queries and generates usedCoordinates.json
(or so, not 100% sure about the naming)
• network retrieves usedCoordinates.json
using apolloUsedCoordinates()
• networks generates __Schema.kt
, CustomerType.kt
, etc...
• app retrieves the existing generated files from apolloMetadata()
and generates Operation1.kt
, Fragment1.kt
, etc...mbonnin
05/03/2024, 2:18 PMmbonnin
05/03/2024, 2:19 PMalwaysGenerateTypesMatching.set(listOf(".*"))
might be good enough or maybe even better than trying to auto detectMarco Pierucci
05/03/2024, 2:20 PMMarco Pierucci
05/03/2024, 2:20 PMMarco Pierucci
05/03/2024, 2:20 PMMarco Pierucci
05/03/2024, 2:20 PMmbonnin
05/03/2024, 2:20 PMMarco Pierucci
05/03/2024, 2:25 PMMarco Pierucci
05/03/2024, 2:25 PM