Skip to content

Commit

Permalink
Use native API when possible (#3338)
Browse files Browse the repository at this point in the history
* Use native API when possible'

* Fix TS typings

* chore(dependencies): updated changesets for modified dependencies

* More

* Fix tsconfig parse

* Fix for v15

* Fix Benchmark suite

* Fix TypeScript

* Dedupe dependencies

* Fix mocking

* ..

* chore(dependencies): updated changesets for modified dependencies

* Fix

* Skip sveltekit in leak tests

* Prettier

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
ardatan and github-actions[bot] authored Jul 1, 2024
1 parent 19fa816 commit 4252e3d
Show file tree
Hide file tree
Showing 80 changed files with 1,403 additions and 4,508 deletions.
6 changes: 6 additions & 0 deletions .changeset/@graphql-yoga_graphiql-3338-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@graphql-yoga/graphiql': patch
---
dependencies updates:
- Added dependency [`tslib@2.6.3` ↗︎](https://www.npmjs.com/package/tslib/v/2.6.3) (to
`dependencies`)
7 changes: 7 additions & 0 deletions .changeset/graphql-yoga-3338-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'graphql-yoga': patch
---
dependencies updates:
- Updated dependency [`@whatwg-node/server@^0.9.36`
↗︎](https://www.npmjs.com/package/@whatwg-node/server/v/0.9.36) (from `^0.9.33`, in
`dependencies`)
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ module.exports = {
'babel-plugin-transform-typescript-metadata',
['@babel/plugin-proposal-decorators', { legacy: true }],
'babel-plugin-parameter-decorator',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-class-properties',
],
};
1 change: 1 addition & 0 deletions benchmark/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"baseUrl": "./",
"outDir": "dist",
"target": "ES2019",
"module": "Node16",
"moduleResolution": "node16"
},
"include": ["./start-server.ts"],
Expand Down
2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"@pulumi/pulumi": "3.116.1",
"@types/node": "18.16.16",
"tsx": "^3.12.7",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
3 changes: 2 additions & 1 deletion e2e/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { exec } from 'node:child_process';
import { setTimeout as setTimeout$ } from 'node:timers/promises';
import { promisify } from 'node:util';

export const execPromise = promisify(exec);
Expand Down Expand Up @@ -41,7 +42,7 @@ export async function waitForEndpoint(
e.message,
);

await new Promise(resolve => setTimeout(resolve, timeout));
await setTimeout$(timeout);
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/aws-lambda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"aws-cdk-lib": "2.83.0",
"esbuild": "0.17.19",
"ts-node": "10.9.1",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
4 changes: 2 additions & 2 deletions examples/azure-function/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"devDependencies": {
"@azure/functions": "4.0.0",
"esbuild": "0.17.19",
"tslib": "2.5.3",
"typescript": "5.1.6"
"tslib": "2.6.3",
"typescript": "5.5.2"
}
}
3 changes: 2 additions & 1 deletion examples/bun-yoga-ws/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { setTimeout as setTimeout$ } from 'node:timers/promises';
import Bun from 'bun';
import { makeHandler } from 'graphql-ws/lib/use/bun';
import { createSchema, createYoga } from 'graphql-yoga';
Expand All @@ -21,7 +22,7 @@ const schema = createSchema({
let counter = 0;
const spinnerFrames = ['\u25D4', '\u25D1', '\u25D5', '\u25D0'];
while (counter < loadTime) {
await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for a second
await setTimeout$(1000); // Wait for a second
yield { dynamicLoading: `Loading ${spinnerFrames[counter % spinnerFrames.length]}` };
counter++;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/cloudflare-advanced/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"devDependencies": {
"ts-loader": "9.4.3",
"typescript": "5.1.6",
"typescript": "5.5.2",
"webpack": "5.86.0",
"wrangler": "3.57.1"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/cloudflare-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"devDependencies": {
"@cloudflare/workers-types": "4.20230518.0",
"@whatwg-node/fetch": "^0.9.17",
"typescript": "5.1.6",
"typescript": "5.5.2",
"wrangler": "3.57.1"
}
}
4 changes: 2 additions & 2 deletions examples/cookies/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"start": "ts-node-dev src/index.ts"
},
"dependencies": {
"@whatwg-node/server-plugin-cookies": "^1.0.0",
"@whatwg-node/server-plugin-cookies": "^1.0.2",
"graphql": "16.6.0",
"graphql-yoga": "workspace:*"
},
"devDependencies": {
"@types/node": "18.16.16",
"ts-node": "10.9.1",
"ts-node-dev": "2.0.0",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/defer-stream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
},
"devDependencies": {
"ts-node": "10.9.1",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
9 changes: 4 additions & 5 deletions examples/defer-stream/src/yoga.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { setTimeout as setTimeout$ } from 'node:timers/promises';
import { createSchema, createYoga } from 'graphql-yoga';
import { useDeferStream } from '@graphql-yoga/plugin-defer-stream';
import { renderGraphiQL } from '@graphql-yoga/render-graphiql';

const wait = (time: number) => new Promise(resolve => setTimeout(resolve, time));

const typeDefs = /* GraphQL */ `
type Query {
"""
Expand Down Expand Up @@ -59,15 +58,15 @@ const resolvers = {
async *alphabet(_, { waitFor }) {
for (const character of alphabet) {
yield character;
await wait(waitFor);
await setTimeout$(waitFor);
}
},
fastField: async () => {
await wait(100);
await setTimeout$(100);
return 'I am speed';
},
slowField: async (_, { waitFor }) => {
await wait(waitFor);
await setTimeout$(waitFor);
return 'I am slow';
},
},
Expand Down
2 changes: 1 addition & 1 deletion examples/error-handling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"devDependencies": {
"ts-node": "10.9.1",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
3 changes: 2 additions & 1 deletion examples/express/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { setTimeout as setTimeout$ } from 'node:timers/promises';
import express from 'express';
import { createSchema, createYoga } from 'graphql-yoga';

Expand Down Expand Up @@ -27,7 +28,7 @@ export function buildApp(app: ReturnType<typeof express>) {
countdown: {
async *subscribe(_, { from }) {
for (let i = from; i >= 0; i--) {
await new Promise(resolve => setTimeout(resolve, 1000));
await setTimeout$(1000);
yield { countdown: i };
}
},
Expand Down
3 changes: 2 additions & 1 deletion examples/fastify-modules/src/modules/basic/providers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { setTimeout as setTimeout$ } from 'node:timers/promises';
import { inspect } from 'node:util';
import { CONTEXT, Inject, Injectable, Scope } from 'graphql-modules';

Expand All @@ -17,7 +18,7 @@ export class BasicProvider {

public async *getCountdown(from: number) {
for (let i = from; i >= 0; i--) {
await new Promise(resolve => setTimeout(resolve, 1000));
await setTimeout$(1000);
yield i;
}
}
Expand Down
16 changes: 1 addition & 15 deletions examples/fastify/__integration-tests__/fastify.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import request from 'supertest';
import { fetch } from '@whatwg-node/fetch';
import { eventStream } from '../../../packages/graphql-yoga/__tests__/utilities.js';
import { createDeferred } from '../../../packages/testing-utils/create-deferred.js';
import { buildApp } from '../src/app.js';

describe('fastify example integration', () => {
Expand Down Expand Up @@ -357,18 +358,3 @@ data"
}
});
});

type Deferred<T = void> = {
resolve: (value: T) => void;
reject: (value: unknown) => void;
promise: Promise<T>;
};

function createDeferred<T = void>(): Deferred<T> {
const d = {} as Deferred<T>;
d.promise = new Promise<T>((resolve, reject) => {
d.resolve = resolve;
d.reject = reject;
});
return d;
}
2 changes: 1 addition & 1 deletion examples/file-upload-nextjs-pothos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"@whatwg-node/fetch": "^0.9.17",
"eslint": "8.42.0",
"eslint-config-next": "13.4.12",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/file-upload-nexus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"devDependencies": {
"@whatwg-node/fetch": "^0.9.17",
"ts-node": "10.9.1",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/gcp-functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"devDependencies": {
"@google-cloud/functions-framework": "3.2.0",
"@types/node": "18.16.16",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/generic-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"cross-env": "7.0.3",
"ts-node": "10.9.1",
"ts-node-dev": "2.0.0",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/graphql-armor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"cross-env": "7.0.3",
"ts-node": "10.9.1",
"ts-node-dev": "2.0.0",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/graphql-sse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"devDependencies": {
"ts-node": "10.9.1",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/graphql-ws/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"cross-env": "7.0.3",
"ts-node": "10.9.1",
"ts-node-dev": "2.0.0",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/hackernews/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"prisma": "5.13.0",
"ts-node": "10.9.1",
"ts-node-dev": "2.0.0",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/hapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"devDependencies": {
"@whatwg-node/fetch": "^0.9.17",
"ts-node": "10.9.1",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/issue-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"@types/node": "18.16.16",
"ts-node": "10.9.1",
"ts-node-dev": "2.0.0",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/koa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
},
"devDependencies": {
"ts-node": "10.9.1",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
3 changes: 2 additions & 1 deletion examples/koa/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { setTimeout as setTimeout$ } from 'node:timers/promises';
import { createSchema, createYoga } from 'graphql-yoga';
import Koa from 'koa';

Expand All @@ -24,7 +25,7 @@ export function buildApp() {
countdown: {
async *subscribe(_, { from }) {
for (let i = from; i >= 0; i--) {
await new Promise(resolve => setTimeout(resolve, 1000));
await setTimeout$(1000);
yield { countdown: i };
}
},
Expand Down
2 changes: 1 addition & 1 deletion examples/live-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"devDependencies": {
"ts-node": "10.9.1",
"ts-node-dev": "2.0.0",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
3 changes: 2 additions & 1 deletion examples/nextjs-app/__integration-tests__/nextjs-app.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { exec } from 'node:child_process';
import { join } from 'node:path';
import { Readable } from 'node:stream';
import { setTimeout as setTimeout$ } from 'node:timers/promises';
import { fetch } from '@whatwg-node/fetch';

const PORT = 3333;
Expand Down Expand Up @@ -127,7 +128,7 @@ export async function waitForEndpoint(
(e as Error).message,
);

await new Promise(resolve => setTimeout(resolve, timeout));
await setTimeout$(timeout);
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss": "3.4.3",
"typescript": "5.1.6"
"typescript": "5.5.2"
},
"devDependencies": {
"@whatwg-node/fetch": "^0.9.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/nextjs-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"next-auth": "4.24.7",
"react": "18.2.0",
"react-dom": "18.2.0",
"tslib": "2.5.3"
"tslib": "2.6.3"
},
"devDependencies": {
"@types/react": "18.2.8",
"eslint": "8.42.0",
"eslint-config-next": "13.4.12",
"typescript": "5.1.6"
"typescript": "5.5.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { exec } from 'node:child_process';
import { join } from 'node:path';
import { Readable } from 'node:stream';
import { setTimeout as setTimeout$ } from 'node:timers/promises';
import { fetch } from '@whatwg-node/fetch';

const PORT = 3334;
Expand Down Expand Up @@ -120,7 +121,7 @@ export async function waitForEndpoint(
(e as Error).message,
);

await new Promise(resolve => setTimeout(resolve, timeout));
await setTimeout$(timeout);
}
}

Expand Down
Loading

0 comments on commit 4252e3d

Please sign in to comment.