Closed mbrowne closed 2 years ago
Hi @mbrowne I'm not sure if I understand your question. This library is an HTTP client. Everything else is up to you. By default this library throws on HTTP errors (>= 200 && <= 399). You can overwrite that behavior by overwriting onResponse
. The thrown error is converted to an ApolloError and internal details aren't exposed.
Ok, so if I understand correctly, there's no built-in mechanism to await
the result and return the body
from it, but there is a built-in (default) mechanism to handle errors. I was comparing this library to apollo-datasource-rest
, where it's slightly more abstract, making the syntax simpler. So I was just confirming that this library is intended to be a bit lower-level (which obviously also gives you more control).
where it's slightly more abstract, making the syntax simpler. So I was just confirming that this library is intended to be a bit lower-level (which obviously also gives you more control).
Yes
Hi, I read the docs for this repo and also the Apollo docs for data sources, and I'm just wondering if this is the intended usage from a resolver function:
This is of course for a simple case, where only the body of the response matters, and not response headers, etc. It seems a bit inconvenient to have to access
.body
on the result for every method, so I'm thinking about creating a wrapperget()
method:Would that be consistent with how this library is meant to be used, or am I missing something?