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

parseIncludes ignores sparse field set on included data #498

Open
nivv opened this issue Dec 9, 2019 · 1 comment
Open

parseIncludes ignores sparse field set on included data #498

nivv opened this issue Dec 9, 2019 · 1 comment
Labels

Comments

@nivv
Copy link

nivv commented Dec 9, 2019

I'm trying to figure out how to specify which fields to select when including a resource. But I can't get it to work. I've been looking through the Manager-class and I found this:

fractal/src/Manager.php

Lines 194 to 214 in a38f0b7

// Matches multiple instances of 'something(foo|bar|baz)' in the string
// I guess it ignores : so you could use anything, but probably don't do that
preg_match_all('/([\w]+)(\(([^\)]+)\))?/', $allModifiersStr, $allModifiersArr);
// [0] is full matched strings...
$modifierCount = count($allModifiersArr[0]);
$modifierArr = [];
for ($modifierIt = 0; $modifierIt < $modifierCount; $modifierIt++) {
// [1] is the modifier
$modifierName = $allModifiersArr[1][$modifierIt];
// and [3] is delimited params
$modifierParamStr = $allModifiersArr[3][$modifierIt];
// Make modifier array key with an array of params as the value
$modifierArr[$modifierName] = explode($this->paramDelimiter, $modifierParamStr);
}
$this->includeParams[$includeName] = $modifierArr;

Request I'm sending

GET /api-endpoint/producers?include=owner(id|name)

I've also tried the below formats

GET /api-endpoint/producers?include=owner:fields(id|name)
GET /api-endpoint/producers?include=owner:field(id|name)

I found that syntax from another issue: #386

How is it supposed to work?

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 4 weeks if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant