Skip to content

Commit ebf0865

Browse files
nickfloydkfcampbellwolfy1339
authored
feat: v8 (#599)
BREAKING CHANGE: Replace support for Node.js http(s) Agents with documentation on using fetch dispatchers instead BREAKING CHANGE: Remove ability to pass custom request options, except from `method`, `headers`, `body`, `signal`, `data` --------- Co-authored-by: Keegan Campbell <[email protected]> Co-authored-by: wolfy1339 <[email protected]>
1 parent 60e9b57 commit ebf0865

File tree

5 files changed

+41
-61
lines changed

5 files changed

+41
-61
lines changed

README.md

+10-20
Original file line numberDiff line numberDiff line change
@@ -245,35 +245,36 @@ const { data: app } = await requestWithAuth(
245245
</tr>
246246
<tr>
247247
<th align=left>
248-
<code>options.mediaType.format</code>
248+
<code>options.method</code>
249249
</th>
250250
<td>
251251
String
252252
</td>
253253
<td>
254-
Media type param, such as `raw`, `html`, or `full`. See <a href="https://developer.github.com/v3/media/">Media Types</a>.
254+
Any supported <a href="https://developer.github.com/v3/#http-verbs">http verb</a>, case insensitive. <em>Defaults to <code>Get</code></em>.
255255
</td>
256256
</tr>
257257
<tr>
258258
<th align=left>
259-
<code>options.mediaType.previews</code>
259+
<code>options.mediaType.format</code>
260260
</th>
261261
<td>
262-
Array of strings
262+
String
263263
</td>
264264
<td>
265-
Name of previews, such as `mercy`, `symmetra`, or `scarlet-witch`. See <a href="https://developer.github.com/v3/previews/">API Previews</a>.
265+
Media type param, such as `raw`, `html`, or `full`. See <a href="https://developer.github.com/v3/media/">Media Types</a>.
266266
</td>
267267
</tr>
268268
<tr>
269269
<th align=left>
270-
<code>options.method</code>
270+
<code>options.mediaType.previews</code>
271271
</th>
272272
<td>
273-
String
273+
Array of strings
274274
</td>
275275
<td>
276-
Any supported <a href="https://developer.github.com/v3/#http-verbs">http verb</a>, case insensitive. <em>Defaults to <code>Get</code></em>.
276+
Name of previews, such as `mercy`, `symmetra`, or `scarlet-witch`. See <a href="https://docs.github.com/graphql/overview/schema-previews">GraphQL Schema Previews</a>.
277+
Note that these only apply to GraphQL requests and have no effect on REST routes.
277278
</td>
278279
</tr>
279280
<tr>
@@ -299,18 +300,7 @@ const { data: app } = await requestWithAuth(
299300
Set request body directly instead of setting it to JSON based on additional parameters. See <a href="#data-parameter">"The `data` parameter"</a> below.
300301
</td>
301302
</tr>
302-
<tr>
303-
<th align=left>
304-
<a name="options-request-agent"></a>
305-
<code>options.request.agent</code>
306-
</th>
307-
<td>
308-
<a href="https://nodejs.org/api/http.html#http_class_http_agent">http(s).Agent</a> instance
309-
</td>
310-
<td>
311-
Node only. Useful for custom proxy, certificate, or dns lookup.
312-
</td>
313-
</tr>
303+
314304
<tr>
315305
<th align=left>
316306
<code>options.request.fetch</code>

package-lock.json

+20-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"dependencies": {
2525
"@octokit/endpoint": "^8.0.1",
2626
"@octokit/request-error": "^4.0.1",
27-
"@octokit/types": "^10.0.0",
27+
"@octokit/types": "^11.0.0",
2828
"is-plain-object": "^5.0.0",
2929
"universal-user-agent": "^6.0.0"
3030
},

src/fetch-wrapper.ts

+10-17
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,16 @@ export default function fetchWrapper(
3636
);
3737
}
3838

39-
return fetch(
40-
requestOptions.url,
41-
Object.assign(
42-
{
43-
method: requestOptions.method,
44-
body: requestOptions.body,
45-
headers: requestOptions.headers as HeadersInit,
46-
redirect: requestOptions.redirect,
47-
// duplex must be set if request.body is ReadableStream or Async Iterables.
48-
// See https://fetch.spec.whatwg.org/#dom-requestinit-duplex.
49-
...(requestOptions.body && { duplex: "half" }),
50-
},
51-
// `requestOptions.request.agent` type is incompatible
52-
// see https://github.com/octokit/types.ts/pull/264
53-
requestOptions.request as any,
54-
),
55-
)
39+
return fetch(requestOptions.url, {
40+
method: requestOptions.method,
41+
body: requestOptions.body,
42+
headers: requestOptions.headers as HeadersInit,
43+
signal: (requestOptions as any).signal,
44+
data: (requestOptions as any).data,
45+
// duplex must be set if request.body is ReadableStream or Async Iterables.
46+
// See https://fetch.spec.whatwg.org/#dom-requestinit-duplex.
47+
...(requestOptions.body && { duplex: "half" }),
48+
})
5649
.then(async (response) => {
5750
url = response.url;
5851
status = response.status;

test/request.test.ts

-19
Original file line numberDiff line numberDiff line change
@@ -561,25 +561,6 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w==
561561
);
562562
});
563563

564-
it("options.request.signal is passed as option to fetch", function () {
565-
return request("/", {
566-
request: {
567-
// We pass a value that is not an `AbortSignal`, and expect `fetch` to
568-
// throw an exception complaining about the value
569-
signal: "funk",
570-
},
571-
})
572-
.then(() => {
573-
throw new Error("Should not resolve");
574-
})
575-
576-
.catch((error) => {
577-
// We can't match on the entire string because the message differs between
578-
// Node versions.
579-
expect(error.message).toMatch(/AbortSignal/);
580-
});
581-
});
582-
583564
it("options.request.fetch", function () {
584565
return request("/", {
585566
request: {

0 commit comments

Comments
 (0)