feat: use a method to get response body details on demand#1218
feat: use a method to get response body details on demand#1218
Conversation
WalkthroughThe Changes
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
v2/pkg/engine/resolve/loader.go(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: SkArchon
PR: wundergraph/graphql-go-tools#1203
File: v2/pkg/engine/resolve/loader.go:63-67
Timestamp: 2025-07-02T15:28:02.122Z
Learning: In the graphql-go-tools codebase, result structs are consistently initialized with non-nil bytes.Buffer instances, making additional nil checks for res.out unnecessary defensive programming.
v2/pkg/engine/resolve/loader.go (1)
Learnt from: SkArchon
PR: wundergraph/graphql-go-tools#1203
File: v2/pkg/engine/resolve/loader.go:63-67
Timestamp: 2025-07-02T15:28:02.122Z
Learning: In the graphql-go-tools codebase, result structs are consistently initialized with non-nil bytes.Buffer instances, making additional nil checks for res.out unnecessary defensive programming.
🔇 Additional comments (2)
v2/pkg/engine/resolve/loader.go (2)
67-71: Double-check lifetime ofres.out– shared pointer could be mutated later
newResponseInfostores the same pointer tores.out.
If any later code writes to or resets that buffer (e.g. a pool reuse), the slice returned byGetResponseBody()will change underneath consumers.Consider:
- Passing a copy (
bytes.NewBuffer(res.out.Bytes())) when long-lived or cross-goroutine access is expected, or- Clearly documenting that the buffer must be treated as read-only and is stable for the lifetime of the callback.
62-64: Add nil-guard to prevent panic when the buffer is absentfunc (ri *ResponseInfo) GetResponseBody() string { - return ri.responseBody.String() + if ri == nil || ri.responseBody == nil { + return "" + } + return ri.responseBody.String() }This preserves current semantics when the buffer is present while avoiding a runtime crash in the admittedly rare case that callers invoke the method on an uninitialised struct.
⛔ Skipped due to learnings
Learnt from: SkArchon PR: wundergraph/graphql-go-tools#1203 File: v2/pkg/engine/resolve/loader.go:63-67 Timestamp: 2025-07-02T15:28:02.122Z Learning: In the graphql-go-tools codebase, result structs are consistently initialized with non-nil bytes.Buffer instances, making additional nil checks for res.out unnecessary defensive programming.
…to-get-response-body-details
🤖 I have created a release *beep* *boop* --- ## [2.0.0-rc.201](v2.0.0-rc.200...v2.0.0-rc.201) (2025-07-09) ### Features * use a method to get response body details on demand ([#1218](#1218)) ([3964286](3964286)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added the ability to retrieve response body details on demand. * **Documentation** * Updated the changelog to include details for version 2.0.0-rc.201. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Motivation
We want to allow the EngineLoader hook to be able to access the response body, however we do not know for sure whether the the hook will want to access the response body string or not, thus instead of exposing the stringified version directly we expose a method that can be called on demand by the hook.
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Refactor
Checklist