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.

Better documentation/error handling regarding relationship paths

See original GitHub issue

It appears that the path needs to be the plural of the model you are referencing.

In the docs we see the example of User.relationship({ path: 'posts', ref: 'Post', refPath: 'author' });

But in this case changing path to anything other than posts causes problems. The docs say: “path - the path of the relationship reference on the Model” which I don’t think quite makes this clear.

Further, if you do set it to something other than posts, no errors are ever thrown, but the admin ui stops working properly, and the browsers console logs errors like: Uncaught TypeError: Cannot read property 'expandColumns' of undefined but if you didn’t open your browsers console you’d never see any error messages, it just wouldn’t work properly.

Is it intended that that path has to be the name of the model the relationship is with? If yes, could the documentation be clearer here? Should we add some kind of check that throws a meaningful error for this? If no, then this is a bug that needs fixing.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:25 (20 by maintainers)

github_iconTop GitHub Comments

1reaction
jstockwincommented, May 13, 2016

@creynders if you are correct, and path should just be any name which the user decides, then there is a bug, since it has to be the name of the model.

From the docs, my understanding was that path should be the user-readable name which will be displayed alongside the user, telling you which posts they have published (in the setting of your example). Whereas refPath would be displayed alongside the posts, and say which user authored the post.

However, it appears that path MUST be the model in question. I.e. I think your example would break unless you change path from articles to posts.

If your example should work, then this is a bug. If this is intended behaviour, then the docs are misleading. IMO this is a bug, and your example should work, but happy to be told otherwise.

0reactions
JHerculesVWcommented, Sep 5, 2018

Will do, though this article is pretty high on the search results for this topic, so I thought I’d save the next person some time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error handling: Modeling the unhappy path | by Federico Gaule
Modeling the unhappy path (exceptions / errors); Handling errors and ... Here you can find really good documentation about this datatype.
Read more >
Best Practices for exceptions - .NET - Microsoft Learn
Learn best practices for exceptions, such as using try/catch/finally, handling common conditions without exceptions, and using predefined .
Read more >
Error Handlers | MuleSoft Documentation
The Error Handler component routes an error to the first On-Error component that matches the error. For more complex error handling configurations at...
Read more >
Error Handling in Microflows | Mendix Documentation
When an error occurs inside a microflow, a Java exception is raised that contains information about the error that occurred. Inside a custom ......
Read more >
A mostly complete guide to error handling in JavaScript.
stack on the error object. What happens when we throw an exception? Exceptions are like an elevator going up: once you throw one,...
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