Skip to content

Don't skip afterFetch in cases where there's no response body. - #35

Merged
jkeen merged 4 commits into
graphiti-api:mainfrom
zpencerq:keep_afterfetch
Jul 27, 2026
Merged

Don't skip afterFetch in cases where there's no response body.#35
jkeen merged 4 commits into
graphiti-api:mainfrom
zpencerq:keep_afterfetch

Conversation

@zpencerq

@zpencerq zpencerq commented Jul 11, 2019

Copy link
Copy Markdown
Contributor

The original error was that the afterFetch middleware functions weren't being called because of various short-circuiting logic within Request#_handleResponse.

Behavior changes

  • When sending a DELETE and getting a 200 response, it will now try to parse that body. Prior to this change-set, it would skip.
  • An invalid JSON document is now determined by both data and meta being undefined rather than just data (aside from a JSON parse error).
    • This is informed by the previous link as well, since only meta being defined is valid.
  • afterFetch calls happen with json=null in the case of a 204 No Content.
    • Presumably this will affect existing middlewares.

Questions:

  • The spec for deleting resources does not specify if a response body MUST be returned. However, you could interpret that "a deletion request has been accepted for processing ... and no content is returned" requires that a 204 be returned by the server. Should we remove the ability for non-204 responses to be empty?

  • The default json body of null was chosen instead of an empty object because it's representing the absence of a body; I figured just {} would be confusing (but I also don't like giving people NPE). Do you think we should introduce some Null Object default that'll explain where it came from (empty body) on field access?

For some reason, the prior method of constructing a Response
was having a status code of 200.
@jkeen
jkeen changed the base branch from master to main July 26, 2026 23:14
@jkeen
jkeen merged commit db52073 into graphiti-api:main Jul 27, 2026
2 checks passed
github-actions Bot pushed a commit that referenced this pull request Jul 27, 2026
## [0.11.0](v0.10.25...v0.11.0) (2026-07-27)

### Features

* add support for constructor assignment for collections ([#109](#109)) ([36a223a](36a223a))
* middleware.afterFilters can now set a newResponse to use (permit retry or re-rerouting request) ([#100](#100)) ([5970ad9](5970ad9))
* singular Resource Handling (read/write operations) ([#98](#98)) ([0f0ec91](0f0ec91))

### Bug Fixes

* declare type definitions on EventBus ([#75](#75)) ([7074b1d](7074b1d)), closes [#54](#54)
* don't skip afterFetch in cases where there's no response body. ([#35](#35)) ([db52073](db52073))
* encode query parameters regardless of the browser ([#104](#104)) ([e964909](e964909))
* remove all marked-for-destruction relations, not every other one ([#137](#137)) ([f3dcbe6](f3dcbe6)), closes [#63](#63)
* self referential relationships will not longer silently fail ([dd2247e](dd2247e)), closes [#110](#110)
* validation error when relationship has nested records ([#101](#101)) ([abf6b5d](abf6b5d))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants