Marco Pierucci
11/16/2023, 12:15 PMextra.grapqhqls
.
I've made a fragment on that object and thats what Im querying but upong inspecting the cache I cant see entries for those object/types ( I woudl expect something similar to "author(\"id\": \"au456\")": {"id": "au456", "name": "Pierre Bordage"}
Marco Pierucci
11/16/2023, 12:15 PMmbonnin
11/16/2023, 12:32 PMmbonnin
11/16/2023, 12:33 PMOPERATION_DOCUMENT
mbonnin
11/16/2023, 12:34 PMMarco Pierucci
11/16/2023, 12:48 PMCan you double check that the id is present in the generated query document (in your operation companion objectOPERATION_DOCUMENT
Not exactly sure what you mean bit is does not look likes it?
fragment componentInfo on Component { fieldsetId fieldsetType id type assets { __typename ...assetInfo } text integer float boolean selection list isMutable }
Marco Pierucci
11/16/2023, 12:48 PMAlso if you can share the type + extension + query that'd help a lot investigating thisSure
Marco Pierucci
11/16/2023, 12:48 PMextend type Component @typePolicy(keyFields: "id")
Marco Pierucci
11/16/2023, 12:49 PMtype Component {
fieldsetId: UUID!
fieldsetType: String! @deprecated(reason: "Use fieldsetTemplateCode")
fieldsetTemplateCode: TaskTemplateName!
id: UUID!
createdAt: DateTime
updatedAt: DateTime
lastEditedBy: OESUserType
type: ComponentType!
boolean: Boolean
selection: [ComponentSelectionType!]
list: [String!]
text: String
assets: [FileAsset!]
integer: Int
float: Float
isMutable: Boolean!
label: String
comments: [Comment!]
}
Marco Pierucci
11/16/2023, 12:49 PMFetchWorkOrder($id: ID!) {
workOrder(id: $id) {
...workOrderInfo
}
validFieldsetOptions(
workOrderId: $id
) {
value
label
}
}
fragment workOrderInfo on WorkOrderType {
externalId
type
status
template {
label
value
}
project {
property {
id
postcode
address
coordinates {
latitude
longitude
}
}
customer {
id
accountNumber
name
phone
email
familyName
givenName
}
}
fieldsets {
...fieldSetInfo
}
project {
type
... customerType
... propertyType
}
}
fragment fieldSetInfo on Fieldset {
id
type
status
fieldsetDescription
components {
...componentInfo
}
isComplete
}
fragment componentInfo on Component {
fieldsetId
fieldsetType
id
type
assets {
...assetInfo
}
text
integer
float
boolean
selection
list
isMutable
}
mbonnin
11/16/2023, 12:57 PMComponent:$id
?mbonnin
11/16/2023, 12:58 PMfragment componentInfo on Component { fieldsetId fieldsetType id type assets { __typename ...assetInfo } text integer float boolean selection list isMutable }
I wanted to double check that the selection for Component was containing id
, which is the caseMarco Pierucci
11/16/2023, 1:02 PMThanks! That looks correct at first glance. And you're not seeing a cache entry forExactly! I do see entries like?Component:$id
workOrder({"id":"J-7E494E4C"}).fieldsets.13.components.0
But not for Component. Not sure if the extension its being picked up but other than have it on the extra.grapqhqls file I dont think Im suposed to to anything else?mbonnin
11/16/2023, 1:03 PMSorry I missed that earlier. It should be justextra.grapqhqls
extra.graphqls
(there's an extra 'q', could it be just that?)Marco Pierucci
11/16/2023, 1:04 PMmbonnin
11/16/2023, 1:06 PMcacheKeyGenerator
, right?Marco Pierucci
11/16/2023, 1:07 PMMarco Pierucci
11/16/2023, 1:07 PMApolloClient.Builder()
.okHttpClient(
builder.addInterceptor(authenticationInterceptor)
.addInterceptor(headerInterceptor)
.build()
)
.serverUrl(environment.current.endpoint.oes + GRAPH_QL_PATH)
.addCustomScalarAdapter(Date.type, GraphQLDateConverter())
.doNotStore(true)
.normalizedCache(SqlNormalizedCacheFactory(APOLLO_CACHE_DB)) // TODO this is not KMP friendly, change when moving into shared
.fetchPolicy(FetchPolicy.NetworkOnly)
.addCustomScalarAdapter(DateTime.type, GraphQLDateTimeConverter())
.addCustomScalarAdapter(Time.type, GraphQLTimeToLocalTimeConverter())
.build()
Marco Pierucci
11/16/2023, 1:07 PMmbonnin
11/16/2023, 1:08 PMmbonnin
11/16/2023, 1:11 PMCacheKeyGenerator
(around here) and investigate why you're not going into the keyFields.isNotEmpty()
branchmbonnin
11/16/2023, 1:12 PMobj["__typename"] == "Component"
or you will hit the breakpoint many many timesMarco Pierucci
11/16/2023, 1:12 PMMarco Pierucci
11/16/2023, 1:19 PMfun CompiledNamedType.keyFields(): List<String> {
return when (this) {
is InterfaceType -> keyFields
is ObjectType -> keyFields
else -> emptyList()
}
Si I go through that, and its effectively a a ObjectTypeMarco Pierucci
11/16/2023, 1:19 PMkeyFIelds
property is emptyMarco Pierucci
11/16/2023, 1:20 PMMarco Pierucci
11/16/2023, 1:21 PMMarco Pierucci
11/16/2023, 1:21 PMapollo {
service("core") {
packageName.set("energy.octopus.fieldservices.base.core.libraries.network.datasource.graphql")
mapScalar("DateTime", "org.threeten.bp.ZonedDateTime")
mapScalar("Date", "org.threeten.bp.LocalDate")
mapScalar("UUID", "kotlin.String")
mapScalar("Time", "org.threeten.bp.LocalTime")
generateAsInternal.set(false)
schemaFile.set(file("src/main/graphql/schema.graphqls"))
srcDir([file("src/main/graphql")])
introspection {
endpointUrl.set("<https://api.oes-test.systems/api/v1/graphql>")
schemaFile.set(file("src/main/graphql/schema.graphqls"))
}
}
mbonnin
11/16/2023, 1:22 PM$packageName.type.Component
mbonnin
11/16/2023, 1:22 PMpublic class Component {
public companion object {
public val type: ObjectType =
ObjectType.Builder(name = "Component").keyFields(listOf("id")).build()
}
}
mbonnin
11/16/2023, 1:23 PMkeyFields
call is not generated in your case indeed, that's interestingmbonnin
11/16/2023, 1:23 PMschemaFile.set
?mbonnin
11/16/2023, 1:24 PMschemaFile
expects a single merged schema so it will not pick up any type extensionMarco Pierucci
11/16/2023, 1:25 PMmbonnin
11/16/2023, 1:25 PMsrcDir
. If you want to specify your schema files explicitly, you can do
schemaFiles.set(listOf(file("src/main/graphql/schema.graphqls"), file("src/main/graphql/extra.graphqls"))
Marco Pierucci
11/16/2023, 1:26 PMmbonnin
11/16/2023, 1:27 PMMarco Pierucci
11/16/2023, 1:32 PMMarco Pierucci
11/16/2023, 1:32 PMMarco Pierucci
11/16/2023, 1:32 PMmbonnin
11/16/2023, 1:32 PM