-
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
writeFragment
not working with @apollo/client@rc.9
#6495
Comments
If I use Here is my resolver using the above query, which is using the same fragments. import {
MutationResolvers,
Query as State
} from 'src/@types/schema~';
import {TabSettings} from '../../schema/queries';
export default {
tabSettingsSelect (
_root,
{
index,
name
},
{cache}
) {
const {tabSettings}: State = cache.readQuery({
query: TabSettings
});
const select = {
...tabSettings?.select,
index,
name
};
const data = {
tabSettings: {
...tabSettings,
select
}
};
cache.writeQuery({
data,
query: TabSettings
});
return select;
}
} as MutationResolvers; |
While it is now possible to call In other words, I would guess that the following code will fix the problem: cache.writeFragment({
id: "ROOT_QUERY", // new
data,
fragment: TabSettingsQuery,
fragmentName: 'TabSettingsQuery'
}); but that seems more complicated than |
Sure enough, that works! However, the data does have {
"tabSettings": {
"select": {
"index": 2,
"name": "home",
"__typename": "TabSettingsSelect"
},
"__typename": "TabSettings"
}
} I tried adding |
Ahh, that needs to be In general, |
That makes sense. const data = {
__typename: 'Query',
tabSettings: {
...tabSettings,
select
}
}; It's alright though. I think I am getting a better grasp at what is going on. |
Yep! That's exactly the right mindset. |
Intended outcome:
After updating from
@apollo/client@3.0.0-beta.50
to@apollo/client@rc.9
, updating the cache in a resolver usingcache.writeFragment
no longer works.Actual outcome:
Cache does not update and no errors are thrown.
How to reproduce the issue:
These are the following fragments and query:
This is my resolver:
Versions
I am currently using
@apollo/client@rc.9
but I have the above issue with every version after@apollo/client@3.0.0-beta.50
.The text was updated successfully, but these errors were encountered: