question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

non-global dataIdFromObject?

See original GitHub issue

When I write an implementation for dataIdFromObject, it seems like if I have two entities with the same ID that they’ll end up at the same place in the store. Is there a way to implement a non-global dataIdFromObject function? Or alternatively have access to the path for the data so that that can be considered when assigning an ID?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
helfercommented, Sep 24, 2016

dataIdFromObject is specifically to tell apollo client that two objets with different paths are actually the same. If you don’t want that, you can just not assign it an id, in which case apollo client will use the path.

1reaction
kesnecommented, Sep 28, 2016

@helfer That’s pretty unfortunate. It seems less than ideal to require adding __typename to every query to get entity mapping working. It seems like this situation would be a common one based on how most people store their data?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring the Apollo Client cache - Apollo GraphQL Docs
dataIdFromObject. Function. A function that takes a response object and returns a unique identifier to be used when normalizing the data in the...
Read more >
Accessing Query Variables inside dataIdFromObject ... - GitHub
I want to access the query variables to set the key in local cache since my query doesn't have id and identical by...
Read more >
Apollo Cache – Angular - GraphQL Code Generator
dataIdFromObject : A function that takes a data object and returns a unique identifier to be used when normalizing the data in the...
Read more >
apollo-link-state and how do I access the local state / cache?
url}/graphql`, opts: { credentials: 'include' } }), addTypename: true, dataIdFromObject });. I am passing in an empty object for my resolvers as ...
Read more >
Interacting with cached data - Apollo GraphQL - w3resource
const todo = client.readFragment({ id: ..., // `id` is any id that could be returned by `dataIdFromObject`. fragment: gql` fragment myTodo ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found