Hi! I'm trying to migrate over to the new normaliz...
# apollo-kotlin
s
Hi! I'm trying to migrate over to the new normalized cache, having followed the docs for Relay-style pagination, but I'm getting a
NullPointerException
crash in
ConnectionMetadataGenerator.metadataForObject
that I'm having a hard time understanding 🧡
I've created a
CacheManager
that I'm providing when building my
ApolloClient
, using
ConnectionMetadataGenerator(Pagination.connectionTypes)
and a
ConnectionRecordMerger
, alongside both Apollo's in-memory and SQLite caches chained together. I've got a number of schema extensions (happy to share in full), but I thought the key part would be that I've specified
connectionFields
on our
Query
type via a
@typePolicy
directive. Wrapping
ConnectionMetadataGenerator
and forwarding
metadataForObject
so that I can examine the
obj
and
context
being passed in, I can see a large number of
null
objects. I'm not exactly sure how to debug this exception and crash though – I'd love any pointers as I'm probably making a mistake somewhere!
b
is it a project you could share so I could have a look?
s
It isn't something I'm able to share unfortunately (plus our project and schema is pretty sizeable)
b
Maybe you could extract only the relevant pieces in a minimal project that shows the issue? From what you said it looks like you did all that's needed but there's probably a small detail missing πŸ˜…. There's a sample using pagination here, maybe you could try to compare with what you have.
are you in the "simple" case, aka vanilla relay style?
s
Yep, simple vanilla Relay style
βœ… 1
I'll double check against that sample
πŸ‘ 1
Comparing against that sample, nothing jumped out as being obviously wrong in our project. But, I've narrowed down the issue to a specific set of fields being requested (via fragments) as part of a single query, without them there's no issue.
b
Hmm interesting. That doesn't ring a bell... Might be a bug!
s
Would there be any benefit to sharing a trimmed down version of our schema (relevant parts), plus query & fragments, either here or in a GH issue? Or would that not be particularly helpful in diagnosing this?
b
Yes that would be perfect!
s
Hi, it was a bit tricky to just get the relevant parts of our schema, queries and extensions but I've zipped them up here. If you're able to give any insights (or anything that seems potentially odd for normalized cache writes) just from that, I'd be really grateful. I've left a comment or two, but essentially if
defaultTags
aren't fetched in the calendar fragment (
calendar.graphql
), or
calendar
isn't fetched as part of the event fragment (
event.graphql
) 'upstream' from that when querying events, we don't see a
NullPointerException
b
Thanks! I'm off today but will have a look tomorrow!
πŸ‘ 1
s
Thank you!
b
All right I've made a little project using your schema/operations - at the moment I don't repro the NPE. This is probably because of the response I crafted here, which may not trigger the issue? Could you tweak the project, maybe replace with a response that triggers the issue?
πŸ™ 1
s
Ah thanks, tweaking now! This looks like a really good isolated way to test – I hadn't thought about testing with a mock Apollo server admittedly
πŸ‘ 1
Hi, sorry for the silence – I hoped to have a more satisfying update or resolution, but right now I haven't even been able to reproduce the original issue in our own project, perplexingly
b
Odd! πŸ‘€
were you always using the same version?
s
Yep, always using the
1.0.0-alpha.1
normalized cache artifacts with Apollo 4.2.0, that hasn't changed since I started migrating over
b
all right. Well, odd πŸ™‚ Hope you'll catch it so we can continue trying to understand the issue.
s
I'll let you know if I get to dig into it again!
πŸ‘ 1