generated from apollographql/typescript-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Version Packages #93
Merged
Merged
Version Packages #93
Conversation
This file contains 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
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
github-actions
bot
force-pushed
the
changeset-release/main
branch
3 times, most recently
from
November 24, 2022 00:04
c686198
to
270aeb6
Compare
github-actions
bot
force-pushed
the
changeset-release/main
branch
10 times, most recently
from
December 3, 2022 11:12
8f88cbc
to
46c021b
Compare
github-actions
bot
force-pushed
the
changeset-release/main
branch
11 times, most recently
from
December 12, 2022 17:08
86897ae
to
6e11700
Compare
github-actions
bot
force-pushed
the
changeset-release/main
branch
5 times, most recently
from
December 15, 2022 00:00
4d5b91b
to
2312582
Compare
github-actions
bot
force-pushed
the
changeset-release/main
branch
3 times, most recently
from
December 19, 2022 23:23
be35f46
to
7fcaea8
Compare
github-actions
bot
force-pushed
the
changeset-release/main
branch
2 times, most recently
from
December 31, 2022 10:34
4c3407a
to
ce782e6
Compare
github-actions
bot
force-pushed
the
changeset-release/main
branch
from
January 3, 2023 19:24
ce782e6
to
40eac5c
Compare
Note that this is reasonably ready for release but we're waiting for some vacations to wrap up :) |
github-actions
bot
force-pushed
the
changeset-release/main
branch
2 times, most recently
from
January 7, 2023 16:55
930c7fb
to
ba6923d
Compare
github-actions
bot
force-pushed
the
changeset-release/main
branch
from
January 10, 2023 00:18
ba6923d
to
e7c18dc
Compare
trevor-scheer
force-pushed
the
changeset-release/main
branch
from
January 10, 2023 00:57
6e036c5
to
e5f74dc
Compare
glasser
reviewed
Jan 10, 2023
trevor-scheer
approved these changes
Jan 10, 2023
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.
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
@apollo/datasource-rest@5.0.0
Major Changes
#89
4a249ec
Thanks @trevor-scheer! - This change restores the full functionality ofwillSendRequest
whichpreviously existed in the v3 version of this package. The v4 change introduced a
regression where the incoming request's
body
was no longer included in theobject passed to the
willSendRequest
hook, it was alwaysundefined
.For consistency and typings reasons, the
path
argument is now the firstargument to the
willSendRequest
hook, followed by theAugmentedRequest
request object.
#115
be4371f
Thanks @glasser! - TheerrorFromResponse
method now receives an options object withurl
,request
,response
, andparsedBody
rather than just a response, and the body has already been parsed.#110
ea43a27
Thanks @trevor-scheer! - Update defaultcacheKeyFor
to include methodIn its previous form,
cacheKeyFor
only used the URL to calculate the cache key. As a result, whencacheOptions.ttl
was specified, the method was ignored. This could lead to surprising behavior where a POST request's response was cached and returned for a GET request (for example).The default
cacheKeyFor
now includes the request method, meaning there will now be distinct cache entries for a given URL per method.#88
2c3dbd0
Thanks @glasser! - When passingparams
as an object, parameters withundefined
values are now skipped, like withJSON.stringify
. So you can write:and if
query
is not provided, thequery
parameter will be left off of the URL instead of given the valueundefined
.As part of this change, we've removed the ability to provide
params
in formats other than this kind of object or as anURLSearchParams
object. Previously, we allowed every form of input that could be passed tonew URLSearchParams()
. If you were using one of the other forms (like a pre-serialized URL string or an array of two-element arrays), just pass it directly tonew URLSearchParams
; note that the feature of strippingundefined
values will not occur in this case. For example, you can replacethis.get('post', { params: [['query', query]] })
withthis.get('post', { params: new URLSearchParams([['query', query]]) })
. (URLSearchParams
is available in Node as a global.)#100
2e51657
Thanks @glasser! - Instead of memoizing GET requests forever in memory, only apply de-duplication during the lifetime of the original request. Replace thememoizeGetRequests
field with arequestDeduplicationPolicyFor()
method to determine how de-duplication works per request.To restore the surprising infinite-unconditional-cache behavior of previous versions, use this implementation of
requestDeduplicationPolicyFor()
(which replacesdeduplicate-during-request-lifetime
withdeduplicate-until-invalidated
):To restore the behavior of
memoizeGetRequests = false
, use this implementation ofrequestDeduplicationPolicyFor()
:#107
4b2a6f9
Thanks @trevor-scheer! - RemovedidReceiveResponse
hookThe naming of this hook is deceiving; if this hook is overridden it becomes
responsible for returning the parsed body and handling errors if they occur. It
was originally introduced in
Apollo server 2.0. - RESTDataSource access to full response obj (headers,...) apollo-server#1324, where the author
implemented it due to lack of access to the complete response (headers) in the
fetch methods (get, post, ...). This approach isn't a type safe way to
accomplish this and places the burden of body parsing and error handling on the
user.
Removing this hook is a prerequisite to a subsequent change that will introduce
the ability to fetch a complete response (headers included) aside from the
provided fetch methods which only return a body. This change will reinstate the
functionality that the author of this hook had originally intended in a more
direct manner.
#95
c59b82f
Thanks @glasser! - Simplify interpretation ofthis.baseURL
so it works exactly like links in a web browser.If you set
this.baseURL
to an URL with a non-empty path component, this may change the URL that your methods talk to. Specifically:this.get('/foo')
now replace the entire URL path fromthis.baseURL
. If you did not intend this, writethis.get('foo')
instead.this.baseURL
has a non-empty path and does not end in a trailing slash, paths such asthis.get('foo')
will replace the last component of the URL path instead of adding a new component. If you did not intend this, add a trailing slash tothis.baseURL
.If you preferred the v4 semantics and do not want to make the changes described above, you can restore v4 semantics by overriding
resolveURL
in your subclass with the following code from v4:As part of this change, it is now possible to specify URLs whose first path segment contains a colon, such as
this.get('/foo:bar')
.#121
32f8f04
Thanks @glasser! - We now write to the shared HTTP-header-sensitive cache in the background rather than before the fetch resolves. By default, errors talking to the cache are logged withconsole.log
; overridecatchCacheWritePromiseErrors
to customize. If you callfetch()
, the result object has ahttpCache.cacheWritePromise
field that you canawait
if you want to know when the cache write ends.Minor Changes
#117
0f94ad9
Thanks @renovate! - If your providedcache
is created withPrefixingKeyValueCache.cacheDangerouslyDoesNotNeedPrefixesForIsolation
(new in@apollo/utils.keyvaluecache@2.1.0
), thehttpcache:
prefix will not be added to cache keys.#114
6ebc093
Thanks @glasser! - Allow specifying the cache key directly as acacheKey
option in the request options. This is read by the default implementation ofcacheKeyFor
(which is still called).#106
4cbfd36
Thanks @glasser! - Previously, RESTDataSource doubled the TTL used with its shared header-sensitive cache when it may be able to use the cache entry after it goes stale because it contained theETag
header; for these cache entries, RESTDataSource can set theIf-None-Match
header when sending the REST request and the server can return a 304 response telling RESTDataSource to reuse the old response from its cache. Now, RESTDataSource also extends the TTL for responses with theLast-Modified
header (which it can validate withIf-Modified-Since
).#110
ea43a27
Thanks @trevor-scheer! - Provide head() HTTP helper methodSome REST APIs make use of HEAD requests. It seems reasonable for us to provide this method as we do the others.
It's worth noting that the API differs from the other helpers. While bodies are expected/allowed for other requests, that is explicitly not the case for HEAD requests. This method returns the request object itself rather than a parsed body so that useful information can be extracted from the headers.
#114
6ebc093
Thanks @glasser! - Allow specifying the options passed tonew CachePolicy()
via ahttpCacheSemanticsCachePolicyOptions
option in the request options.#121
32f8f04
Thanks @glasser! - If you're usingnode-fetch
as your Fetcher implementation (the default) and the response has header names that appear multiple times (such asSet-Cookie
), then you can use thenode-fetch
-specific API(await myRestDataSource.fetch(url)).response.headers.raw()
to see the multiple header values separately.#115
be4371f
Thanks @glasser! - NewthrowIfResponseIsError
hook allows you to control whether a response should be returned or thrown as an error. Partially replaces the removeddidReceiveResponse
hook.#116
ac767a7
Thanks @glasser! - ThecacheOptions
function andcacheOptionsFor
method may now optionally be async.#90
b66da37
Thanks @trevor-scheer! - Add a new overridable methodshouldJSONSerializeBody
for customizing body serialization behavior. This method should return aboolean
in order to inform RESTDataSource as to whether or not it should callJSON.stringify
on the request body.#110
ea43a27
Thanks @trevor-scheer! - Add publicfetch
methodUsers previously had no well-defined way to access the complete response (i.e. for header inspection). The public API of HTTP helper methods only returned the parsed response body. A
didReceiveResponse
hook existed as an attempt to solve this, but its semantics weren't well-defined, nor was it a type safe approach to solving the problem.The new
fetch
method allows users to "bypass" the convenience of the HTTP helpers in order to construct their own full request and inspect the complete response themselves.The
DataSourceFetchResult
type returned by this method also contains other useful information, like arequestDeduplication
field containing the request's deduplication policy and whether it was deduplicated against a previous request.Patch Changes
#121
609ba1f
Thanks @glasser! - When de-duplicating requests, the returned parsed body is now cloned rather than shared across duplicate requests. If you override theparseBody
method, you should also overridecloneParsedBody
to match.#105
8af22fe
Thanks @glasser! - The fetch Response now consistently has a non-emptyurl
property; previously,url
was an empty string if the response was read from the HTTP cache.#90
b66da37
Thanks @trevor-scheer! - Correctly identify and serialize all plain objects (like those with a null prototype)#94
834401d
Thanks @renovate! - Update@apollo/utils.fetcher
dependency to v2.0.0#89
4a249ec
Thanks @trevor-scheer! -string
andBuffer
bodies are now correctly included on the outgoing request.Due to a regression in v4, they were ignored and never sent as the
body
.string
andBuffer
bodies are now passed through to the outgoing request(without being JSON stringified).