Expose JSON:API includes so callers can hydrate tags and other relationships - #229
Open
PeteBishwhip wants to merge 1 commit into
Open
Expose JSON:API includes so callers can hydrate tags and other relationships#229PeteBishwhip wants to merge 1 commit into
PeteBishwhip wants to merge 1 commit into
Conversation
Adds a $query parameter to server() and organizationSite() so callers can pass include=tags (or any other supported include) through to the API. The top-level included document is preserved on hydrated resources and exposed via a new included($name) helper that resolves relationship pointers against it. Fixes #228.
PeteBishwhip
marked this pull request as ready for review
July 2, 2026 20:14
Member
Author
brunogaspar
approved these changes
Jul 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #228.
Querying a server or a site through the SDK returned an empty
relationshipsblock and no way to hydrate related resources such as tags. Two things were missing:server()andorganizationSite()did not accept a$queryargument, so callers could not pass?include=tags(or any other JSON:API include).includeddocument, the SDK only consumed the top-leveldataenvelope and discardedincluded, so relationship identifiers stayed unresolved.Changes
server(string $organizationSlug, int $serverId, array $query = [])- new$queryparameter, forwarded to the API.organizationSite(string $organizationSlug, int $siteId, array $query = [])- same treatment.Resourcenow exposespublic array $included(populated from the response) and a smallincluded(string $name): arrayhelper that resolvesrelationships[$name].datapointers against the sharedincludeddocument. Handles array, single-object, and null relationship shapes.Forge::newResource(),Forge::transformCollection(),Forge::paginatedCollection(), andCursorPaginator::nextPage()thread theincludeddocument through to hydrated resources so it is available on collection items too.included()helper tests cover: server with tag includes, site with tag includes, site with a single-object relationship (latestDeployment) plus a nullserverrelationship, and a paginated server collection propagating the sharedincludeddocument.[Unreleased]entry referencing Tags missing from a response when I query a resource #228.Usage
The same pattern works on
organizationSite()and on collection methods likeservers()/serverSites().Testing
4 new tests added