-
Notifications
You must be signed in to change notification settings - Fork 46
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
Returning ref values for leaf properties #132
Comments
This is expected behavior. Falcor only follows references if you attempt to JH On Sep 10, 2015, at 10:30 AM, Jed Clinger notifications@github.com wrote: Hello. I'm not sure if this is a bug or not. I was hoping I could model a resource with a specific prop being a Given a router defined with the routes below, the router will return the [ With this call from the browser model: var model = new falcor.Model({source: new The router will return this payload instead of traversing the reference: { And the falcor model on the client will convert that to this: { This seems like a useful usecase to me, but please correct my thinking if If this is a bug, I believe it stems from this line: Since suffix.length will always be 0 in this case, the ref path will never — You received this message because you are subscribed to the Google Groups |
@noonian if you want to retrieve the value beyond the reference, you can add // With 'null' at the end of the path, the router will see 'refProp'
// as a "branch" key. If 'refProp' is a reference, it'll be followed.
// If it's a value, path-resolution will short-circuit at the value
// and 'null' will be ignored.
var model = new falcor.Model({source: new falcor.HttpDataSource('/model.json') });
model
.get(['thing', 'refProp', null])
.then((res) => {
console.log(res);
}); |
Ah I see, that makes sense. Thanks for the explanation. |
One of the reasons we have a documented this feature yet is that we are not JH On Sep 10, 2015, at 2:33 PM, Jed Clinger notifications@github.com wrote: Ah I see, that makes sense. Thanks for the explanation. — You received this message because you are subscribed to the Google Groups |
I ran into this need also: #175 I closed the issue, but referencing it here for posterity. |
What about making it so when you request a path to a reference, it could behave conditionally?
That's how I assumed it would work based on everything I tried up to now, actually. The reason it would be nice to be able to alias leaf nodes like this is it would avoid some round tripping in my scenario. Can show examples if needed. |
@greim you're right. since the router has full knowledge of all valid paths, it could make this distinction. need buy-in from @jhusain and @michaelbpaulson. I know they've got a lot on their plates. |
Hello. I'm not sure if this is a bug or not.
I was hoping I could model a resource with a specific prop being a reference to a specific prop of a different resource. In my data model this happens occasionally where ids that are really refs to resources are 'mapped' to just the email of the linked resource for example.
Given a router defined with the routes below, the router will return the ref array as if it was a primitive value for the resource at path ['thing', 'refProp'].
With this call from the browser model:
The router will return this payload instead of traversing the reference:
And the falcor model on the client will convert that to this:
This seems like a useful usecase to me, but please correct my thinking if not supporting this is by design.
If this is a bug, I believe it stems from this line: https://github.com/Netflix/falcor-router/blob/master/src/run/recurseMatchAndExecute.js#L78
Since
suffix.length
will always be0
in this case, the ref path will never be expanded/followed.The text was updated successfully, but these errors were encountered: