Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error for overwriting object with no id #28

Open
tizmagik opened this issue Jul 28, 2018 · 1 comment
Open

Better error for overwriting object with no id #28

tizmagik opened this issue Jul 28, 2018 · 1 comment
Labels
🐛 debugging Feature requests that help users more easily debug issues project-apollo-client (legacy) LEGACY TAG DO NOT USE

Comments

@tizmagik
Copy link

tizmagik commented Jul 28, 2018

Carry over from

apollographql/apollo-client#819

@dcecile
Copy link

dcecile commented Nov 8, 2019

As a workaround to debug my missing ID, I added console errors to my ID function:

const cache = new InMemoryCache({
    dataIdFromObject: object => {
        if (
            !object.id !==
            (object.__typename.endsWith("Connection") ||
                object.__typename.endsWith("Edge") ||
                object.__typename.endsWith("Mutation"))
        ) {
            if (!object.id) {
                console.error("Missing id for GraphQL data", object)
            } else {
                console.error("Unexpected id for GraphQL data", object)
            }
        }
        return object.id
    },
})

The whole object together with the timing of the error message were enough to narrow down the queries and find the missing ID.

@jerelmiller jerelmiller added the 🐛 debugging Feature requests that help users more easily debug issues label Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 debugging Feature requests that help users more easily debug issues project-apollo-client (legacy) LEGACY TAG DO NOT USE
Projects
None yet
Development

No branches or pull requests

4 participants