Remove redundant follow('self') traversals#103
Closed
Conversation
Co-authored-by: michaellocher <17722361+michaellocher@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove follow('self') where applicable
Remove redundant follow('self') traversals
Nov 18, 2025
There was a problem hiding this comment.
Pull Request Overview
This PR eliminates redundant HAL navigation steps by removing unnecessary follow('self') calls, improving code efficiency and clarity. The changes fall into two categories: using direct self link hrefs where the link is already available, and removing explicit self traversals for root resources where self is implicit.
- Direct use of self link href via
traverson.from(this.getLink('self').href).jsonHal()instead ofthis.newRequest().follow('self') - Root resource methods simplified by removing
.follow('self')where the traversal already points to the root - Cleanup of obsolete request options handling in
Resource.save()
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/resources/publicAPI/EntryResource.ts | Optimized both conditional branches in resolve() to use direct self link traversal |
| src/resources/datamanager/TemplateResource.ts | Added traverson import and updated resolve() to use direct self link traversal |
| src/resources/Resource.ts | Updated del(), resolve(), and save() methods to use direct self link traversal; removed obsolete requestOptions cleanup |
| src/PublicAPI.ts | Removed redundant .follow('self') from resolve() and getSchema() since root traversal is implicit |
| src/Core.ts | Removed redundant .follow('self') from follow() method when reloading root resource |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
|
The change with |
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.
Eliminate unnecessary
follow('self')calls where the self link is already available or implicit. This removes an extra traversal step in the traverson HAL navigation.Changes
Resource methods using existing self link:
Resource.del(),Resource.resolve(),Resource.save()- Direct traverson request from self hrefEntryResource.resolve()- Same optimization for both conditional branchesTemplateResource.resolve()- Added traverson import and direct requestRoot resource access (self is implicit):
Core.follow()- Remove redundant follow when reloading rootPublicAPI.resolve()andPublicAPI.getSchema()- Root request without explicit selfCleanup:
Resource.save()(no longer applicable with fresh request builders)Example
For root resources where self is implicit:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.