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

Nested fields and expand in REST API #8061

Closed
ghost opened this issue Apr 13, 2015 · 9 comments
Closed

Nested fields and expand in REST API #8061

ghost opened this issue Apr 13, 2015 · 9 comments

Comments

@ghost
Copy link

ghost commented Apr 13, 2015

Facebook Graph API also uses fields and expand query parameters in REST APIs. Now Yii2 supports same but upto 1 level. Can we do nested fields like Facebook, for example:

GET graph.facebook.com/me?fields=albums.limit(5){name, photos.limit(2){name, picture, tags.limit(2)}},posts.limit(5)

In above example, my albums are limits to 5 only and again in each album only name and photos fields will be fetched with max 2 photos per album with again photos nested to give max 2 tags per photo. Along with albums, it will also give max 5 posts of the user.

Now limit(n) would be advance feature but I think nested expand is something easy to implement and really necessary feature to have.

PS: On separate note if you plan to support nested limit, you can also look into offset and sort on nested elements.

@fernandezekiel
Copy link
Contributor

as @qiangxue said, this is more of a rare case
#303 (comment)
i am however looking forward on how to implement this

@lichunqiang
Copy link
Contributor

Hi all

What's going on about this question.

@akaNightmare
Copy link

hi, maybe it make sense implement simple functionality like:

 expand="user.contacts"

(nested relations)

@mdmunir
Copy link
Contributor

mdmunir commented Aug 25, 2015

My solusion #6844 (comment)

@samdark samdark added this to the 2.0.x milestone Sep 9, 2015
@Yiivgeny
Copy link

+1

@josegustavo
Copy link

How I can convert this:

id,name,items{id,title,categories{id,title,image},relates{id,title,image},image},image

in this:

{ 'id' : {}, 'name' : {}, 'items' : { 'id' : {}, 'title' : {}, 'categories' : { 'id' : {}, 'title' : {}, 'image' : {} }, 'relates' : { 'id' : {}, 'title' : {}, 'image' : {} }, 'image' : {} }, image : {} }

@tunecino
Copy link
Contributor

tunecino commented Jun 2, 2017

GET graph.facebook.com/me?fields=albums.limit(5){name, photos.limit(2){name, picture, tags.limit(2)}},posts.limit(5)

This looks more like a query language than REST. Maybe a complete implementation of GraphQL as extension would be better than adding it as feature to current REST?

some resources:
https://facebook.github.io/graphql/
https://philsturgeon.uk/api/2017/01/24/graphql-vs-rest-overview/
https://github.com/webonyx/graphql-php

@Faryshta
Copy link
Contributor

Faryshta commented Jun 4, 2017

to me it looks like a proposal for aggregated reporting in SOA.

http://arnon.me/soa-patterns/aggregated-reporting/

which i have no idea how to implement in php

@yii-bot
Copy link

yii-bot commented Apr 5, 2018

Issue moved to yiisoft/yii-api#11

@yii-bot yii-bot closed this as completed Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants