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

Search results are never full entities - handle them differently? #3

Open
g105b opened this issue Dec 8, 2023 · 0 comments
Open

Search results are never full entities - handle them differently? #3

g105b opened this issue Dec 8, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@g105b
Copy link
Contributor

g105b commented Dec 8, 2023

When you search for something, the actual type of Entity returned is quite sparse. For example:

$client = new SpotifyClient($clientId, $clientSecret);
$searchResults = $client->search->query(
	new FilterQuery(
		upc: $upc
	),
	new SearchFilter(EntityType::album),
);

/** @var SHIFT\Spotify\Entity\Album $album - this is the object we're talking about **/
$album = $searchResults->albums->items[0];

echo $album->name; // this works fine
echo $album->artists[0]->name; // there are no artists!
echo $album->label; // there is no label!

To fix this, an extra call is required to "get" the full album details:

$album = $client->albums->get($searchResults->albums->items[0]->id);
// Now we can see $album->artists, $album->label, etc.

This makes sense to avoid recursive large objects, but it should be indicated to the developer that this is happening.

My first idea was to return an SearchResultAlbum instead of Album, and all SearchResult types should have a method to return an inflated version of the Entity they represent.

@g105b g105b added the enhancement New feature or request label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant