Skip to content

feat: configurable Fetch parsers #9997

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

feat: configurable Fetch parsers #9997

wants to merge 1 commit into from

Conversation

runspired
Copy link
Contributor

@runspired runspired commented May 21, 2025

This PR

  • enables per-handler and per-request tailoring of how the Fetch handler will parse the response text
  • adds default handlers for text/xml/html in addition to json
  • changes Fetch to attempt to use the best parser instead of always assuming json

Open questions:

  • What do pluggable streaming parsers look like?

json streaming formats like ndjson, jsonl, json-seq and ccdj can likely incrementally parse the response. Some formats can likely do a streaming parse without text decoding.

  • Should this just be some utils?

we could produce a series of fetch-handler utils to aide construction of this sort of handler instead.

  • Is there a better pattern for this overall?

The Fetch handler offers broad utility beyond its JSON parse, but maybe there's a better way to surface that utility.

  • What about Errors parsing?

This approach still assumes a json parse of errors falling back to simple body-as-string.

  • Should xml2json be a default parser?

It has a lot of utility especially for ML and is rather easy and small to achieve.

  • What about transforming uploads?

Currently fetch does not handle adding a body to the request, probably should not begin doing so here .... but ... if no body is present we could introduce auto-serialization of the data property. In which case we'd want serialization utils here.

@runspired runspired added 🎯 canary PR is targeting canary (default) 🏷️ feat This PR introduces a new feature labels May 21, 2025
@github-project-automation github-project-automation bot moved this to needs triage in EmberData May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎯 canary PR is targeting canary (default) 🏷️ feat This PR introduces a new feature
Projects
Status: needs triage
Development

Successfully merging this pull request may close these issues.

1 participant