Apollo-client: Better error for overwriting object with no id

Created on 21 Oct 2016  路  19Comments  路  Source: apollographql/apollo-client

Rather than "the application attempted to write an object with no provided id"

馃檹 help-wanted

Most helpful comment

I'm having a ton of trouble with this issue. It's extremely difficult to track down when the app gets large with a lot of fragments. I use a unique nodeId for each entity's ID field. If I forget to add a nodeId in any single entity anywhere inside any fragment, mutation, or query it causes Apollo to blow up with this error.

As suggested in the initial issue, adding a path would be extremely helpful.

All 19 comments

Also, add path to these errors.

This issue has never come up in the last 5 months, so I think we're good here.

I'm having a ton of trouble with this issue. It's extremely difficult to track down when the app gets large with a lot of fragments. I use a unique nodeId for each entity's ID field. If I forget to add a nodeId in any single entity anywhere inside any fragment, mutation, or query it causes Apollo to blow up with this error.

As suggested in the initial issue, adding a path would be extremely helpful.

Thanks @clayne11, let's make sure we print a better error message here!

This issue has been automatically marked as stale becuase it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to Apollo Client!

Keeping this open.

Having the same issues as @clayne11

I am still getting this issue.

Same here

also getting this issue!

Ok here's what I found:

When we have this:

  • NO batching (because this problem doesn't appear when both requests are merged into 1)
  • 1 of the 2 requests asks for an id field, and the other one doesn't, example :
// component 1
    config {
      id
      version
    }
// component 2
    config {
      updatedAt
    }

=> if the component 1's request arrives first, apollo doesn't know how to handle the 2nd request. If not, it's OK.
=> if both of the components ask for an id field, its ok.
=> if none of the components ask for an id field, its ok.

I find it quite logical, and I don't think this should be considered as a bug

hope this helps

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to Apollo Client!

I think apollo client should generate(or any other action) a unique id to resolve this issue, not throwing an error.
It's not a perfect solution as @goldo do, but really helpful for now.
In other hand, id field is not necessary for some entities.

@joint-song if your data contains id field it means there should be several of them, right ? If it does, apollo will need to know how to handle them, and merge them.
If your data doesn't contains any IDs and is unique (like a global config query for example), the merge should be simple since there's only 1 element.
i don't know how apollo could handle them any otherway

EDIT: But I understand there should be another way of identifying them, with other field than "id", indeed

I think we can improve this with the goal of better messages / error handling in the post 2.0 launch

I just hit this error today. Haven't yet dug into the cause/why I'm seeing it, but a path to the error sounds like it might be useful. 馃槄

After some discussion, I think its best to adjust this to be an error. We've added some better logging around when this is happening as well

馃憤 to error; we added it as one in Hermes, and it caught a _ton_ of bugs in our client apps

To help provide a more clear separation between feature requests / discussions and bugs, and to help clean up the feature request / discussion backlog, Apollo Client feature requests / discussions are now being managed under the https://github.com/apollographql/apollo-feature-requests repository.

Migrated to: https://github.com/apollographql/apollo-feature-requests/issues/28

Was this page helpful?
0 / 5 - 0 ratings