How to query normalized cached field

Hi, there!

I am modifying saleor dashboard authentication logic due to some schema changes in our grapql server. Basically, I have tokenCreate mutation which looks like this.

mutation TokenCreate{
  tokenCreate(email: String, password: String) {
    user {
      ...and so on

Here the user field is type of UserRegistration, and cached when response is received.
I see the following cached data on Apollo Client DevTools after calling tokenCreate mutation.

Question: Is it possible to query this cache without query modifier with useQuery?
The problem is that our server doesn’t have specific query to get UserRegistration type object. It only comes as a field of tokenCreate or accountRegister.

If you’re on v3.7.0 or later, you can try out the new useFragment_experimental hook! Hooks (experimental) - Apollo GraphQL Docs (ignore the note about @apollo/client@beta – this hook is still experimental, but it’s now available in the latest stable release)

1 Like

Yes, this is exactly what I need. Thank you.

But it turns out I can’t upgrade to latest version of @apollo/client from 3.4.5 version.
As a temporary (working) solution, I am using reactive variable for user field as an alternative to cache. For that, I need to manually modify reactive variable after tokenCreate mutation.