-
Notifications
You must be signed in to change notification settings - Fork 653
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
Persist Record arguments/metadata with the SQL Json backend #4211
Conversation
✅ Deploy Preview for apollo-android-docs canceled.
|
66415a6
to
c7f0c68
Compare
...nMain/kotlin/com/apollographql/apollo3/cache/normalized/api/internal/JsonRecordSerializer.kt
Outdated
Show resolved
Hide resolved
...nMain/kotlin/com/apollographql/apollo3/cache/normalized/api/internal/JsonRecordSerializer.kt
Outdated
Show resolved
Hide resolved
✅ |
apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/CompiledGraphQL.kt
Outdated
Show resolved
Hide resolved
apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/fieldPolicyArgs.kt
Outdated
Show resolved
Hide resolved
apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/CompiledGraphQL.kt
Show resolved
Hide resolved
recordMerger = CursorPaginationRecordMerger() | ||
) | ||
.serverUrl("unused") | ||
.build() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you're not using any of the ApolloClient
functionality here? If that's the case, you can instanciate an ApolloStore
directly:
ApolloStore(
normalizedCacheFactory = normalizedCacheFactory,
cacheKeyGenerator = cacheKeyGenerator,
metadataGenerator = metadataGenerator,
apolloResolver = apolloResolver,
recordMerger = recordMerger
)
val incomingList = incomingFieldValue as List<*> | ||
val mergedList = mergeLists(existingList, incomingList, existingOffset, incomingOffset) | ||
mergedFields[fieldKey] = mergedList | ||
mergedMetadata[fieldKey] = mapOf("offset" to min(existingOffset, incomingOffset)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using min
doesn't take into account the case where existing and incoming do not join (the early returns in mergeLists
)
.../src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/api/internal/Normalizer.kt
Show resolved
Hide resolved
UsersCursorBasedQuery.Edge("xx44", UsersCursorBasedQuery.Node("44", "Peter", "peter@a.com", "User")), | ||
UsersCursorBasedQuery.Edge("xx45", UsersCursorBasedQuery.Node("45", "Alice", "alice@a.com", "User")), | ||
UsersCursorBasedQuery.Edge("xx46", UsersCursorBasedQuery.Node("46", "Bob", "bob@a.com", "User")), | ||
UsersCursorBasedQuery.Edge("xx47", UsersCursorBasedQuery.Node("47", "Charlie", "charlie@a.com", "User")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you 🐶 🥫 test builders here?
…aphql/apollo3/cache/normalized/api/internal/JsonRecordSerializer.kt Co-authored-by: Martin Bonnin <martin@mbonnin.net>
…s to keep in pagination field names
…/CompiledGraphQL.kt Co-authored-by: Martin Bonnin <martin@mbonnin.net>
Co-authored-by: Martin Bonnin <martin@mbonnin.net>
Co-authored-by: Martin Bonnin <martin@mbonnin.net>
fa2fde3
to
6b18de4
Compare
...nMain/kotlin/com/apollographql/apollo3/cache/normalized/api/internal/JsonRecordSerializer.kt
Show resolved
Hide resolved
* Introduce FieldRecordMerger * Fix badly named FieldMerger
Co-authored-by: Martin Bonnin <martin@mbonnin.net>
Also, add a test/sample for offset based pagination.