Skip to content

sparse fields filter relationships #249

@efinder2

Description

@efinder2

I've started implementing the sparse fieldsets in my application. At first I was surprised how easy it was to add the functionality to my app. Without included relationships is the result as expected. Problem is that the relationships aren't added if I use sparse fieldsets. These could be accomplished by adding the type name to the fieldsets array.

According to the tests this should be working:

$aFieldSets = [
	// Attributes and relationships that should be shown
	'employees'  => ['firstName', 'lastName'],
	'subsidiaries'  => ['name'],
]
$sJson = $this->getJsonEncoder()
		->withLinks($aLinks)
		->withMeta($metaData))
		->withFieldSets($aFieldSets)
		->withIncludedPaths(['subsidiaries'])
		->encodeData($oRecords);

Only if the Fieldset is changed to this, the related data is shown.

$aFieldSets = [
	// Attributes and relationships that should be shown
	'employees'  => ['firstName', 'lastName','subsidiaries'],
	'subsidiaries'  => ['name'],
]

Where could be the problem?

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions