-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performance Improvements around 150% (#1073)
* Faster? * ... * Faster * Fix imports * Bump * Better changesets * Trigger CI
- Loading branch information
Showing
24 changed files
with
357 additions
and
260 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@graphql-yoga/common': patch | ||
--- | ||
|
||
Avoid extra usages of URL constructor which has some performance implications on Node |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
'@graphql-yoga/common': minor | ||
--- | ||
|
||
new option `fetchAPI` has been added; | ||
|
||
User can provide a custom Fetch implementation to Yoga like below; | ||
|
||
```ts | ||
import { fetch, Request, Response, ReadableStream } from 'my-ponyfill' | ||
createServer({ | ||
fetchAPI: { | ||
fetch, | ||
Request, | ||
Response, | ||
ReadableStream, | ||
}, | ||
}) | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
'@graphql-yoga/node': patch | ||
--- | ||
|
||
Use node-fetch by default instead of undici. As discussed in https://github.com/nodejs/undici/issues/1203, `undici`'s fetch implementation has some performance issues compared to `node-fetch` v2. | ||
|
||
So Yoga now uses `node-fetch` by default which doesn't affect the existing users. User can configure `cross-undici-fetch` to revert back this behavior; | ||
|
||
```ts | ||
import { create } from 'cross-undici-fetch' | ||
|
||
createServer({ | ||
fetchAPI: create({ useNodeFetch: false }), | ||
}) | ||
``` |
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 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 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 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 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
let encodeString: (str: string) => Uint8Array | ||
if ('Buffer' in globalThis) { | ||
encodeString = (str) => Buffer.from(str, 'utf-8') | ||
if (globalThis.Buffer) { | ||
encodeString = function encodeStringWithBuffer(str: string) { | ||
return Buffer.from(str, 'utf8') | ||
} | ||
} else { | ||
const textEncoder = new TextEncoder() | ||
encodeString = (str) => textEncoder.encode(str) | ||
encodeString = function encodeStringWithTextEncoder(str: string) { | ||
return textEncoder.encode(str) | ||
} | ||
} | ||
|
||
export { encodeString } |
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 file was deleted.
Oops, something went wrong.
Oops, something went wrong.