Cache: Incoming fields have missing fields if the response's fields are null

The id field is more a common convention than a necessity. I don’t know if you have a common field that you can use as a keyField for those records, but you might also take a look at the “Customizing cache IDs” section of our docs (specifically the dataIdFromObject) where this would allow you to define a global default.

Keep in mind that you don’t have to define a merge function for every non-normalized type. This is only necessary if you have different queries with overlapping data and you want to make sure the fields are merged correctly.

If you have an idea on how to improve this feature, you might consider filing a feature request so we can determine if we can find ways to make this easier.

In your MongoDB database, every object should have a unique _id field. You could either expose that as id on your server, or configure Apollo Client to look for _id instead of id, and add _id to your queries.

Funny thing is, sometimes it removes a field from the cache sometimes it doesn’t.

  query Post {
    post {
      id
      user {
        id
        details {
          a
        }
      }
    }
  }

  query CurrentUserLessDetail {
    currentUser {
      id
      details {
        a
      }
    }
  }

CurrentUserLessDetail query doesn’t completely overwrite User.details. But Post query does.
If you pay enough attention they select the exact same fields of User.

Before you belittle me. I know why it’s happening. CurrentUserLessDetail hits the cache, but Post doesn’t.