Skip to content

Commit 8c674c3

Browse files
Avoid node-fetch on Node 16/18 temporarily & enable detectLeaks on tests (#1794)
* Avoid node-fetch on Node 16/18 temporarily & enable detectLeaks on tests * Go * Go * Go * Seperate Bun Tests * Update Deno example * Disable Apollo & Urql tests * Try runInBand * Log heap usage as well * More * chore(dependencies): updated changesets for modified dependencies * Try CI * Fix * Fix bun tests * .. * chore(dependencies): updated changesets for modified dependencies * Yes * chore(dependencies): updated changesets for modified dependencies * Go * Go * .. Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 992033b commit 8c674c3

File tree

74 files changed

+528
-356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+528
-356
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@graphql-yoga/plugin-apollo-inline-trace': patch
3+
---
4+
5+
dependencies updates:
6+
7+
- Updated dependency [`@whatwg-node/[email protected]` ↗︎](https://www.npmjs.com/package/@whatwg-node/fetch/v/0.4.6) (from `0.4.5`, in `dependencies`)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@graphql-yoga/plugin-apq': patch
3+
---
4+
5+
dependencies updates:
6+
7+
- Updated dependency [`@whatwg-node/[email protected]` ↗︎](https://www.npmjs.com/package/@whatwg-node/fetch/v/0.4.6) (from `0.4.5`, in `dependencies`)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'graphql-yoga': patch
3+
---
4+
5+
dependencies updates:
6+
7+
- Updated dependency [`@whatwg-node/[email protected]` ↗︎](https://www.npmjs.com/package/@whatwg-node/fetch/v/0.4.6) (from `0.4.5`, in `dependencies`)
8+
- Updated dependency [`@whatwg-node/[email protected]` ↗︎](https://www.npmjs.com/package/@whatwg-node/server/v/0.4.10) (from `0.4.7`, in `dependencies`)
9+
- Added dependency [`@graphql-tools/[email protected]` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/8.12.0) (to `dependencies`)

.github/workflows/ci.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ on:
1111
- 'website/**'
1212

1313
jobs:
14-
node:
14+
unit:
1515
name: unit / nodejs v${{ matrix.node-version }}
1616
uses: the-guild-org/shared-config/.github/workflows/ci-node-matrix.yml@main
1717
with:
1818
script: 'yarn build && yarn test'
1919
nodeVersions: '[14,16,18]'
2020

21-
test-integration:
22-
name: Run integration tests
21+
integration:
22+
name: integration / nodejs v${{ matrix.node-version }}
2323
runs-on: ubuntu-latest
2424
strategy:
2525
matrix:
@@ -35,9 +35,6 @@ jobs:
3535
node-version: ${{ matrix.node-version }}
3636
cache: 'yarn'
3737

38-
- name: Setup Bun Runtime
39-
uses: antongolub/action-setup-bun@v1
40-
4138
- name: Cache Node Modules
4239
uses: actions/cache@v3
4340
id: node-modules-cache-test-node
@@ -54,10 +51,9 @@ jobs:
5451
run: yarn build
5552

5653
- name: Run Tests
57-
run: yarn test:integration
54+
run: yarn test:integration --ci
5855

59-
test-esm:
60-
name: esm
56+
esm:
6157
runs-on: ubuntu-latest
6258
steps:
6359
- name: Checkout Repository
@@ -88,6 +84,9 @@ jobs:
8884
- name: Use Deno
8985
uses: denoland/setup-deno@v1
9086

87+
- name: Setup Bun Runtime
88+
uses: antongolub/action-setup-bun@v1
89+
9190
- name: Build Packages
9291
run: yarn build
9392

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ const yoga = createYoga({
5151

5252
const server = createServer(yoga)
5353

54-
server.listen(4000)
54+
server.listen(4000, () => {
55+
console.info('Server is running on http://localhost:4000/graphql')
56+
})
5557
```
5658

5759
## Overview

examples/apollo-federation/gateway/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ async function main() {
1414

1515
// Start the server and explore http://localhost:4000/graphql
1616
const server = createServer(yoga)
17-
server.listen(4000)
17+
server.listen(4000, () => {
18+
console.info('Server is running on http://localhost:4000/graphql')
19+
})
1820
}
1921

2022
main().catch((err) => {
Lines changed: 42 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,59 @@
1-
import { spawn } from 'child_process'
21
import { fetch } from '@whatwg-node/fetch'
32

4-
describe('Bun integration', () => {
5-
let bunProcess: ReturnType<typeof spawn>
6-
let serverUrl: string
7-
8-
beforeAll(async () => {
9-
// Start Bun
10-
bunProcess = spawn('yarn', ['workspace', 'example-bun', 'start'])
3+
import { createYoga, createSchema } from 'graphql-yoga'
114

12-
serverUrl = await new Promise((resolve, reject) => {
13-
bunProcess.stderr?.on('data', (chunk) => {
14-
const chunkString = chunk.toString('utf-8')
15-
console.error(chunk.toString('utf-8'))
16-
if (chunkString.includes('Command failed')) {
17-
reject(new Error('Bun failed to start'))
18-
}
19-
})
5+
import { describe, it, expect } from 'bun:test'
206

21-
bunProcess.stdout?.on('data', (chunk) => {
22-
const chunkString = chunk.toString('utf-8')
23-
console.log(chunk.toString('utf-8'))
24-
if (chunkString.includes('Server is running on')) {
25-
resolve(chunkString.split('Server is running on ')[1])
7+
describe('Bun integration', () => {
8+
const yoga = createYoga({
9+
schema: createSchema({
10+
typeDefs: /* GraphQL */ `
11+
type Query {
12+
greetings: String
2613
}
27-
})
28-
})
29-
})
30-
31-
afterAll(() => {
32-
bunProcess.kill()
14+
`,
15+
resolvers: {
16+
Query: {
17+
greetings: () => 'Hello Bun!',
18+
},
19+
},
20+
}),
3321
})
3422

3523
it('shows GraphiQL', async () => {
36-
const response = await fetch(serverUrl, {
37-
method: 'GET',
38-
headers: {
39-
Accept: 'text/html',
24+
const server = Bun.serve(yoga)
25+
const response = await fetch(
26+
new URL(yoga.graphqlEndpoint, server.hostname).toString(),
27+
{
28+
method: 'GET',
29+
headers: {
30+
Accept: 'text/html',
31+
},
4032
},
41-
})
42-
expect(response.status).toEqual(200)
43-
expect(response.headers.get('content-type')).toEqual('text/html')
33+
)
34+
expect(response.status).toBe(200)
35+
expect(response.headers.get('content-type')).toBe('text/html')
4436
const htmlContents = await response.text()
45-
expect(htmlContents).toContain('Yoga GraphiQL')
37+
expect(htmlContents.includes('GraphiQL')).toBe(true)
38+
server.stop()
4639
})
4740

4841
it('accepts a query', async () => {
49-
const response = await fetch(serverUrl, {
50-
method: 'POST',
51-
headers: {
52-
'Content-Type': 'application/json',
42+
const server = Bun.serve(yoga)
43+
const response = await fetch(
44+
new URL(yoga.graphqlEndpoint, server.hostname).toString(),
45+
{
46+
method: 'POST',
47+
headers: {
48+
'Content-Type': 'application/json',
49+
},
50+
body: JSON.stringify({
51+
query: `{ greetings }`,
52+
}),
5353
},
54-
body: JSON.stringify({
55-
query: `{ greetings }`,
56-
}),
57-
})
54+
)
5855
const result = await response.json()
59-
expect(result).toEqual({
60-
data: {
61-
greetings: 'Hello Bun!',
62-
},
63-
})
56+
expect(result.data.greetings).toBe('Hello Bun!')
57+
server.stop()
6458
})
6559
})

examples/bun/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"license": "MIT",
55
"scripts": {
66
"start": "bun src/index.ts",
7-
"check": "exit 0"
7+
"check": "bun wiptest"
88
},
99
"dependencies": {
1010
"bun-types": "^0.1.5",

examples/bun/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createYoga, createSchema, Repeater } from 'graphql-yoga'
1+
import { createYoga, createSchema } from 'graphql-yoga'
22

33
const yoga = createYoga({
44
schema: createSchema({

examples/bun/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
// "bun-types" is the important part
99
"types": ["bun-types"]
1010
},
11-
"files": ["src/index.ts"]
11+
"files": ["src/index.ts", "__integration-tests__/bun.spec.ts"]
1212
}

0 commit comments

Comments
 (0)