{"action":"created","issue":{"url":"https://api.github.com/repos/dingo/api/issues/777","repository_url":"https://api.github.com/repos/dingo/api","labels_url":"https://api.github.com/repos/dingo/api/issues/777/labels{/name}","comments_url":"https://api.github.com/repos/dingo/api/issues/777/comments","events_url":"https://api.github.com/repos/dingo/api/issues/777/events","html_url":"https://github.com/dingo/api/issues/777","id":123101362,"number":777,"title":"Calling collection without return does not use transformer.","user":{"login":"lukasoppermann","id":813754,"avatar_url":"https://avatars.githubusercontent.com/u/813754?v=3","gravatar_id":"","url":"https://api.github.com/users/lukasoppermann","html_url":"https://github.com/lukasoppermann","followers_url":"https://api.github.com/users/lukasoppermann/followers","following_url":"https://api.github.com/users/lukasoppermann/following{/other_user}","gists_url":"https://api.github.com/users/lukasoppermann/gists{/gist_id}","starred_url":"https://api.github.com/users/lukasoppermann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukasoppermann/subscriptions","organizations_url":"https://api.github.com/users/lukasoppermann/orgs","repos_url":"https://api.github.com/users/lukasoppermann/repos","events_url":"https://api.github.com/users/lukasoppermann/events{/privacy}","received_events_url":"https://api.github.com/users/lukasoppermann/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dingo/api/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/dingo/api/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/dingo/api/milestones/1","html_url":"https://github.com/dingo/api/milestones/v1.0.0","labels_url":"https://api.github.com/repos/dingo/api/milestones/1/labels","id":1472271,"number":1,"title":"v1.0.0","description":"It's been a long time coming, and there's been a few hiccups along the way, but hoping to get a stable 1.0.0 out earlier in the new year.\r\n\r\nThe package as it is is mostly stable, with several bugs cropping up here and there, however I am pleased with where it's at.\r\n\r\nI do not plan to add any more major features, just improve upon what is there until 1.0.0 is tagged.","creator":{"login":"jasonlewis","id":829059,"avatar_url":"https://avatars.githubusercontent.com/u/829059?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonlewis","html_url":"https://github.com/jasonlewis","followers_url":"https://api.github.com/users/jasonlewis/followers","following_url":"https://api.github.com/users/jasonlewis/following{/other_user}","gists_url":"https://api.github.com/users/jasonlewis/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonlewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonlewis/subscriptions","organizations_url":"https://api.github.com/users/jasonlewis/orgs","repos_url":"https://api.github.com/users/jasonlewis/repos","events_url":"https://api.github.com/users/jasonlewis/events{/privacy}","received_events_url":"https://api.github.com/users/jasonlewis/received_events","type":"User","site_admin":false},"open_issues":25,"closed_issues":6,"state":"open","created_at":"2015-12-23T07:20:13Z","updated_at":"2016-08-18T14:40:30Z","due_on":"2016-09-04T00:00:00Z","closed_at":null},"comments":10,"created_at":"2015-12-19T18:00:33Z","updated_at":"2016-08-18T14:42:28Z","closed_at":null,"body":"Hey, so I have a `gallery` item which has many `images` defined via a polymorphic many to many relationship.\r\n\r\nIf I use an include it works fine, but it seems suboptimal, as this will add all images to the include part using the json serializer. As they are not indexed by id in the `include` part of the response, I would have to loop through all of them to figure which one belongs to which gallery. I fear this will drain performance.\r\n\r\nI want to get something like this:\r\n\r\n```javascript\r\n{\r\n\"type\": \"gallery\",\r\n\"id\": \"ab2ccbf9-0c24-3745-983a-44b622eb6924\",\r\n\"attributes\": {\r\n  \"slug\": \"omnis\",\r\n  \"created_at\": \"2015-12-18 15:01:21\",\r\n  \"updated_at\": \"2015-12-18 15:01:21\",\r\n \"images\":  {\r\n  \"data\": [\r\n  {\r\n    \"type\": image,\r\n    \"id\": \"03ebf27f-b494-3ae9-b3c2-a56264d51490\",\r\n    \"path\":\"image/path.png\"\r\n  },\r\n  {\r\n    \"type\": image,\r\n    \"id\": \"eccb16b3-fe29-31b1-9004-8b7f586b9ad4\",\r\n    \"path\":\"image/path.png\"\r\n  }\r\n  ]\r\n }\r\n}\r\n```\r\n\r\nI could achieve something like this by just using the normal laravel relationship in the transformer instead of the include, but this will create 2 problems:\r\n\r\n```php\r\npublic function transform(Gallery $gallery)\r\n    {\r\n        return [\r\n            'id'              => $gallery->id,\r\n            'slug'          => $gallery->slug,\r\n            'images'     => $this->collection($gallery->images, new ImageTransformer, function ($resource, $fractal) {\r\n                $fractal->setSerializer(new DataArraySerializer);\r\n            })->getData(),\r\n            'created_at'    => (string)$page->created_at,\r\n            'updated_at'    => (string)$page->updated_at,\r\n        ];\r\n    }\r\n```\r\n\r\n1. I can not embed via url, because it will always be included\r\n2. The transformer is actually not applied\r\n\r\nAny idea how I can solve this issue?"},"comment":{"url":"https://api.github.com/repos/dingo/api/issues/comments/240744690","html_url":"https://github.com/dingo/api/issues/777#issuecomment-240744690","issue_url":"https://api.github.com/repos/dingo/api/issues/777","id":240744690,"user":{"login":"hskrasek","id":787487,"avatar_url":"https://avatars.githubusercontent.com/u/787487?v=3","gravatar_id":"","url":"https://api.github.com/users/hskrasek","html_url":"https://github.com/hskrasek","followers_url":"https://api.github.com/users/hskrasek/followers","following_url":"https://api.github.com/users/hskrasek/following{/other_user}","gists_url":"https://api.github.com/users/hskrasek/gists{/gist_id}","starred_url":"https://api.github.com/users/hskrasek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hskrasek/subscriptions","organizations_url":"https://api.github.com/users/hskrasek/orgs","repos_url":"https://api.github.com/users/hskrasek/repos","events_url":"https://api.github.com/users/hskrasek/events{/privacy}","received_events_url":"https://api.github.com/users/hskrasek/received_events","type":"User","site_admin":false},"created_at":"2016-08-18T14:42:28Z","updated_at":"2016-08-18T14:42:28Z","body":"@bcarroll22 Internally Dingo is trying to handle eager loads. I'm not sure I'd say it was buggy, but I don't see a ton of documentation on it, and it makes a lot of assumptions. One of those being, you'd name your includes the same as your relationships.\r\n\r\nThe package does have the option to disable the eager loading so you can handle it yourself though."}}
{"actor":{"display_login":"hskrasek"}}