You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm looking into using https://github.com/Mikhus/graphql-fields-list to look ahead into a GralhQL query so bookshelf can fetch the related data at once. The problem is most of keys it returns are not foreign relations in the model, so directly adding them to withRelated would cause error when fetching. Perhaps there can be an option to tell bookshelf to ignore extra withRelated options when they don't exist?
Issue Description
Since the list can have multiple nested levels, simply filtering at the top level would work. And since the fetching process is already traversing down the relations, I figure it might be more efficient to just ignore the errors rather than do another relation building and traversal beforehand. Let me know if there are better way to do this however.
Changing the line in base/eager.js
throw new Error(relationName + ' is not defined on the model.');
to a continue seem to work. Although I'm not too familiar with the code base to know if it might break other parts.
Potentially, this option can also make it ignore functions that doesn't return relation data.
Expected behaviour
Being able to specify withRelated with extra keys in it.
Actual behaviour
Bookshelf throws an error complaining key not found.
The text was updated successfully, but these errors were encountered:
Introduction
I'm looking into using https://github.com/Mikhus/graphql-fields-list to look ahead into a GralhQL query so bookshelf can fetch the related data at once. The problem is most of keys it returns are not foreign relations in the model, so directly adding them to withRelated would cause error when fetching. Perhaps there can be an option to tell bookshelf to ignore extra withRelated options when they don't exist?
Issue Description
Since the list can have multiple nested levels, simply filtering at the top level would work. And since the fetching process is already traversing down the relations, I figure it might be more efficient to just ignore the errors rather than do another relation building and traversal beforehand. Let me know if there are better way to do this however.
Changing the line in base/eager.js
to a
continue
seem to work. Although I'm not too familiar with the code base to know if it might break other parts.Potentially, this option can also make it ignore functions that doesn't return relation data.
Expected behaviour
Being able to specify withRelated with extra keys in it.
Actual behaviour
Bookshelf throws an error complaining key not found.
The text was updated successfully, but these errors were encountered: