# Undefined IDs for mutation results

**URL:** <https://community.apollographql.com/t/undefined-ids-for-mutation-results/6938>\
**Category:** Client SDKs\
**Tags:** client, web\
**Created:** [November 10, 2023, 5:39pm UTC](https://community.apollographql.com/t/undefined-ids-for-mutation-results/6938 "2023-11-10T17:39:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![timscott](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/timscott/32/4735_2.png) [@timscott](https://community.apollographql.com/u/timscott)\
**Post date:** [November 10, 2023, 5:39pm UTC](https://community.apollographql.com/t/undefined-ids-for-mutation-results/6938/1 "2023-11-10T17:39:23Z")

</div>

I’m getting warnings about “Cache data may be lost”, so I decided to check if there are missing IDs by adding a custom function:

```auto
dataIdFromObject(responseObject) {
  const id = defaultDataIdFromObject(responseObject);
  return id;
}

```

Most responseObjects are shaped like this:

```auto
{ 
  "id": "1",
  "__typename": "Event",
  // other fields 
}

```

Those are correctly assigned IDs. But I noticed some like this:

```auto
{
  "event": {
    "id": "1",
    "__typename": "Event",
    // other fields
  }
}

```

I traced this back to a mutation that looks like this:

```auto
mutation DoAThing($id: ID!) {
  event: doAThing(id: $id) {
    id
    // other fields
  }
}

```

So it’s nesting the result for some reason. I tried removing the alias, but it’s the same shape, just not aliased.

What am I doing wrong? Do I need a custom function to handle this case? Seems like a vanilla case.

---

<div class="post-metadata">

**Author:** ![timscott](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/timscott/32/4735_2.png) [@timscott](https://community.apollographql.com/u/timscott)\
**Post date:** [November 10, 2023, 6:05pm UTC](https://community.apollographql.com/t/undefined-ids-for-mutation-results/6938/2 "2023-11-10T18:05:16Z")

</div>

Upon closer examination, it seems that `dataIdFromObject` is being called a second time with the nested object returned from the mutation, so perhaps this is normal behavior.

But now I’m left wondering why I get a warning like:

> Cache data may be lost when replacing the assignment field of a Event object.
> 
> To address this problem (which is not a bug in Apollo Client), define a custom merge function for the Event.assignment field, so InMemoryCache can safely merge these objects:
> 
> existing: [{“\_\_ref”:“Assignment:39”},{“\_\_ref”:“Assignment:38”}]  
> incoming: [{“\_\_ref”:“Assignment:38”}]

`assignments` is one of the other fields noted in the example above, returned from the mutation.

---

<div class="post-metadata">

**Author:** ![Justin\_Gonzalez](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/justin_gonzalez/32/5359_2.png) [@Justin\_Gonzalez](https://community.apollographql.com/u/Justin_Gonzalez)\
**Post date:** [February 6, 2025, 8:47pm UTC](https://community.apollographql.com/t/undefined-ids-for-mutation-results/6938/3 "2025-02-06T20:47:57Z")

</div>


