-
Notifications
You must be signed in to change notification settings - Fork 3
Make ApolloStore aware of the client CustomScalarAdapters #122
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
Comments
Hi! I think it was probably on purpose that the store and client are kind of independent / well isolated as a general good practice, but it's true that the use of custom scalars may not be the most intuitive. An extension on the client could be something like this, fun ApolloClient.readFromStore(operation: Operation) = apolloStore.readOperation(operation, customScalarAdapters) but that would be the equivalent of: executing the query with a |
Good point but there is no equivalent in the client's API for About the API, it's was indeed unexpected for me that the store attached to the client would not know about the custom scalars adapters for the data it's effectively storing. Other alternative options:
|
It makes sense to store the scalar adapters in In all cases, updating the doc sounds like a good thing to do 👍 |
Doc has been updated. I'm keeping this issue open with a new title to keep track of the API change request. Most likely for the next major version |
We have the same issue with the Dispatcher. See this kotlinlang thread |
Summary
When using custom scalars,
apolloStore#readOperations
andapolloStore#writeOperations
may throw an IllegalStateException.This is more an API change request than a real bug (see below)
Version
3.0.0
Description
This is because the custom scalar adapters known to the client, are not known by the store. The client passes down their custom scalar adapters when writing to the store. When accessing directly the store, the custom scalar adapters are not known (it's an optional parameter of
readOperation
&writeOperation
).Below are code snippets:
instead
The text was updated successfully, but these errors were encountered: