Field mapping for edges #435
Comments
👍 When I reviewed the edge support for the first time, basically for the Based on the official docs, Now, the SDK uses mmm, this way we auto cast for example: $graphEdgeMap = array(
'photos' => '\Facebook\GraphNodes\GraphPhoto',
'events' => '\Facebook\GraphNodes\GraphEvent',
); where the key of the array equal to the edge name that extracted from the Graph quiery |
Yeah, the
Yeah,
I think that's fine. We can document that if you want to get a list back as a specific subtype you just used nested request syntax. I actually prefer nested requests as they give me a lot more control over what I'm getting back and it's these types of situations I want to control the edge subtypes. That's why I wrote the Facebook Query Builder. :)
"Yes" to casting by referencing using the edge/field name. But I wouldn't try and extract parts of the URL to guess what subtypes to cast to. One of the worst things about v3 of the PHP SDK was all the guessing it did. It was a nightmare. If you're using nested request syntax, the edges will be returned as a field in the response. Direct Edge Response
{
"data": [
{
"id": "10152749540391510"
. . .
},
. . .
]
} Nested Request Edge Response
{
"photos": {
"data": [
{
"id": "10152749540391510"
. . .
},
. . .
]
}
} |
I'm 👎 on this "just" because one of my proposal refactoring for 5.0 is to remove that static map :) |
@yguedidi Is it just because it's a static? If it were a constant would you be open to supporting it? I wanted to make it a constant but constants don't support arrays. :) Statics are usually used incorrectly about 90% of the time, but this is a situation that really warrants statics since the map is just immutable config. |
@SammyK not really because it's a static, but more about how it's used. Once I got some time, probably later today, I'll open the issue about this with more details ;) |
Sounds good! :) |
Can't wait :) |
Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed. |
Closing this because #437. Re-open if you think it necessary. |
As we think about how we're going to support "non-root node thingies" in #401, it'd be nice to also include support for auto-casting of nodes returned from an edge.
We could reference the edge just as we do with fields and define how to cast each node from that edge.
The SDK already has support for casting edge subtypes so it would just require getting the
$graphObjectMap
feature to support it.The text was updated successfully, but these errors were encountered: