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

store.cache.query(q => q.findRecords('foo')) should validate 'foo' is defined in schema #545

Closed
mindblight opened this issue Oct 30, 2018 · 3 comments · Fixed by #835
Closed
Labels
dx developer experience improvement
Milestone

Comments

@mindblight
Copy link

If foo is not defined in a Stores schema, calling store.cache.query(q => q.findRecords('foo')) throws:

withQuery.tsx:35 Uncaught TypeError: Cannot read property 'values' of undefined
    at findRecords (query-operators.js:18)

It looks like the problem is at line 40 of store/src/cache/query-operators.ts:

let results = Array.from(cache.records(expression.type).values());

cache.records returns undefined which makes .values() throw the above error, which isn't obvious what the problem is. Something like Store could not find 'foo' definition in cache. Did you forget to add it to your schema? would be more helpful. It looks like the other find operations all have a similar version of this.

I'm happy to throw together a PR with the check in place, but I wanted to get thoughts/feedback first.

@dgeb
Copy link
Member

dgeb commented Oct 31, 2018

@mindblight It will be good to improve orbit's DX for common issues like this, so that minor papercuts don't turn into major frustrations.

I agree that your suggestion would be an improvement. Please let me know if you need any guidance in putting together the PR. Thanks!

@dgeb dgeb added the dx developer experience improvement label Nov 28, 2018
@stefan-wullems
Copy link

Is this completed yet? If not I'll make some time to give it a go. I've ran into some pretty frustrated bugs because of this.

@dgeb
Copy link
Member

dgeb commented Sep 12, 2019

@Stefanwullems I don't think this has been tackled yet, so it would be much appreciated if you could improve the DX here. Thanks in advance!

@dgeb dgeb added this to the 0.17 milestone Apr 13, 2021
@dgeb dgeb closed this as completed in #835 Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dx developer experience improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants