-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
InMemoryCacheConfig
interface has no cacheRedirects
property
#5983
Comments
The Sorry for the misleading documentation! It's still a work in progress (hence the "beta" tag), and we will definitely fix this before the final release. |
That's understandable. Thanks for the link! |
I'll leave this issue open until we fix the underlying documentation issue. Feel free to ask any questions you have about the new API in the meantime! |
@benjamn could you provide a minimal FieldPolicy example for a |
Something like this? new InMemoryCache({
typePolicies: {
Query: {
fields: {
user(existingDataFromCache: Reference | undefined, { args, toReference }) {
return existingDataFromCache || toReference({
__typename: "User",
id: args.id,
});
},
},
},
},
}) I think the piece you're missing is You don't necessarily have to pay any attention to new InMemoryCache({
typePolicies: {
Query: {
fields: {
user(_, { args, toReference }) {
return toReference({
__typename: "User",
id: args.id,
});
},
},
},
},
}) |
Hello, I'm a bit confused with the new API, is there a way I can do something like "look in the cache for this id (I suppose this part is working with the provided example), if it's not there, then query the server"? I always wanted this behavior in the old version of apollo but right now I haven't been able to achieve it. For example, sometimes you will go to the list page of a CRUD and then you have all the items in the cache when you go to the detail page, but if you go to the detail page of an item directly (no list page first) then the details of the item are not in the cache and I want to query directly. Can you guide me on how to achieve this? |
This is what the previous example is about... Basically if you return |
Oh great, thanks for explaining :) I wasn't sure if this was the default behavior. |
Updated docs showing the removal of |
Intended outcome:
I am trying to use cache redirects as recommended in Apollo Client 3.0 documentation
and I guess it should work as as in the docs. Or docs should change to match the actual implementation
Actual outcome:
The
tsc
complains thatInMemoryCacheConfig
has nocacheRedirects
property.How to reproduce the issue:
Install
@apollo/client
at version3.0.0-beta.37
, follow the documentation, see the error.Versions
The text was updated successfully, but these errors were encountered: