Skip to content

Wrong identity object in schema in getting started guide of schema-record #9985

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

Open
Jopie01 opened this issue May 12, 2025 · 2 comments
Open

Comments

@Jopie01
Copy link

Jopie01 commented May 12, 2025

I upgraded my packages from 5.4.0-alpha.120 to 5.6.0-alpha.2 and walked into a problem with the schema-record package. I got the error Expected a resource schema and didn't know where it came from. So I digged into the code and found the change at https://github.com/emberjs/data/blob/245ba3cde61cb0690ba7f13739c3b03e5af2e193/packages/schema-record/src/-private/hooks.ts#L17C11-L17C37. As it seems there is now a test to check if the identifier is really a schema.

Looking at

export function isResourceSchema(schema: ResourceSchema | ObjectSchema): schema is ResourceSchema {
where the check is defined, I saw that it looks for a key called kind in the identity object. So I added that data and everything worked again.

However, looking into the getting started guide

identity: { type: '@id', name: 'id' },
I see that there is not a kind key but a type. Shouldn't be that kind as well? Otherwise you will get the same error as I had.

@runspired
Copy link
Contributor

not sure how you got by without kind before but yes the readme there has the wrong thing, will fix, thanks!

@Jopie01
Copy link
Author

Jopie01 commented May 12, 2025

not sure how you got by without kind before

That's easy to explain: The check is added in PR #9757 and since 5.4.0-alpha.144. I came from 5.4.0-alpha.120 and the id field was a derived field in my schema so I had to change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: needs triage
Development

No branches or pull requests

2 participants