diff --git a/benchmark/hello-world/check-server.js b/benchmark/hello-world/check-server.js index b1f3592179..0419e31b32 100644 --- a/benchmark/hello-world/check-server.js +++ b/benchmark/hello-world/check-server.js @@ -1,4 +1,4 @@ -require('cross-undici-fetch') +require('@whatwg-node/fetch') .fetch( `http://localhost:4000/graphql?query=${encodeURIComponent( '{ greetings }', diff --git a/examples/azure-function/src/index.ts b/examples/azure-function/src/index.ts index 8f09a1d3f0..e5cabf933f 100644 --- a/examples/azure-function/src/index.ts +++ b/examples/azure-function/src/index.ts @@ -1,6 +1,6 @@ import { AzureFunction, Context, HttpRequest } from '@azure/functions' import { createServer } from '@graphql-yoga/common' -import { Request } from 'cross-undici-fetch' +import { Request } from '@whatwg-node/fetch' const httpTrigger: AzureFunction = async function ( context: Context, diff --git a/examples/cloudflare-modules/test/index.spec.ts b/examples/cloudflare-modules/test/index.spec.ts index 53a8e855ef..7e7894376c 100644 --- a/examples/cloudflare-modules/test/index.spec.ts +++ b/examples/cloudflare-modules/test/index.spec.ts @@ -1,5 +1,5 @@ import worker from '../src/index.js' -import { Request } from 'cross-undici-fetch' +import { Request } from '@whatwg-node/fetch' import { getIntrospectionQuery } from 'graphql' test('should render GraphiQL', async () => { diff --git a/examples/error-handling/package.json b/examples/error-handling/package.json index b2ab477b9b..c43831ae07 100644 --- a/examples/error-handling/package.json +++ b/examples/error-handling/package.json @@ -8,7 +8,7 @@ }, "dependencies": { "@graphql-yoga/node": "2.13.4", - "cross-undici-fetch": "^0.4.13", + "@whatwg-node/fetch": "^0.0.2", "graphql": "^16.1.0" }, "devDependencies": { diff --git a/examples/error-handling/src/index.ts b/examples/error-handling/src/index.ts index ddf9964445..e2344e6ef2 100644 --- a/examples/error-handling/src/index.ts +++ b/examples/error-handling/src/index.ts @@ -1,5 +1,5 @@ import { createServer, GraphQLYogaError } from '@graphql-yoga/node' -import { fetch } from 'cross-undici-fetch' +import { fetch } from '@whatwg-node/fetch' const users = [ { diff --git a/examples/redis-pub-sub/package.json b/examples/redis-pub-sub/package.json index 887ee03067..a865082ef5 100644 --- a/examples/redis-pub-sub/package.json +++ b/examples/redis-pub-sub/package.json @@ -22,7 +22,7 @@ "@graphql-yoga/node": "2.13.4", "@graphql-yoga/redis-event-target": "0.1.2", "graphql": "16.5.0", - "ioredis": "5.2.1" + "ioredis": "5.2.2" }, "module": "commonjs" } diff --git a/examples/service-worker/test/integration.test.ts b/examples/service-worker/test/integration.test.ts index 93dd21e888..4d54b8f335 100644 --- a/examples/service-worker/test/integration.test.ts +++ b/examples/service-worker/test/integration.test.ts @@ -1,6 +1,6 @@ import { getIntrospectionQuery } from 'graphql' import { createServer } from '@graphql-yoga/common' -import { Request } from 'cross-undici-fetch' +import { Request } from '@whatwg-node/fetch' const listenerMap = new Map>() diff --git a/examples/sveltekit/__tests__/test.ts b/examples/sveltekit/__tests__/test.ts index 3304a421b1..c33e7bf293 100644 --- a/examples/sveltekit/__tests__/test.ts +++ b/examples/sveltekit/__tests__/test.ts @@ -17,7 +17,7 @@ let toSkip = false; describe('SvelteKit integration', () => { beforeAll(async () => { - console.time('Setup SvelteKit tests'); + // console.time('Setup SvelteKit tests'); const nodeVersion = execSync('node -v').toString(); if (nodeVersion.includes('v12')) { @@ -49,7 +49,7 @@ describe('SvelteKit integration', () => { } // How long it took? - console.timeEnd('Setup SvelteKit tests'); + // console.timeEnd('Setup SvelteKit tests'); }, timings.setup.total); beforeEach(async () => { diff --git a/examples/sveltekit/package.json b/examples/sveltekit/package.json index 96321ff62f..31c11a7f01 100644 --- a/examples/sveltekit/package.json +++ b/examples/sveltekit/package.json @@ -32,7 +32,7 @@ "svelte-preprocess": "4.10.7", "tslib": "2.4.0", "typescript": "4.7.4", - "vite": "2.9.14" + "vite": "3.0.2" }, "dependencies": { "@envelop/graphql-jit": "4.4.0", diff --git a/package.json b/package.json index 92edd5ca25..a2bd94bbae 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,6 @@ "resolutions": { "@changesets/apply-release-plan": "6.0.0", "graphql": "16.5.0", - "cross-undici-fetch": "0.4.14", "@types/react": "17.0.39", "@types/react-dom": "17.0.17", "react": "17.0.2", diff --git a/packages/common/__tests__/cors.test.ts b/packages/common/__tests__/cors.test.ts index b81226bf7f..42a3f0b394 100644 --- a/packages/common/__tests__/cors.test.ts +++ b/packages/common/__tests__/cors.test.ts @@ -1,4 +1,4 @@ -import { Request } from 'cross-undici-fetch' +import { Request } from '@whatwg-node/fetch' import { getCORSHeadersByRequestAndOptions, CORSOptions, diff --git a/packages/common/package.json b/packages/common/package.json index 4baa88316e..15c3b2eaf4 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -71,7 +71,7 @@ "@graphql-tools/schema": "^8.5.0", "@graphql-tools/utils": "^8.8.0", "@graphql-yoga/subscription": "^2.2.2", - "cross-undici-fetch": "^0.4.13", + "@whatwg-node/fetch": "^0.0.2", "dset": "^3.1.1", "tslib": "^2.3.1" }, diff --git a/packages/common/src/plugins/requestParser/POSTMultipart.ts b/packages/common/src/plugins/requestParser/POSTMultipart.ts index 328713c7b1..86b817b7fd 100644 --- a/packages/common/src/plugins/requestParser/POSTMultipart.ts +++ b/packages/common/src/plugins/requestParser/POSTMultipart.ts @@ -17,7 +17,7 @@ export async function parsePOSTMultipartRequest( try { requestBody = await request.formData() } catch (e: unknown) { - // Trick for cross-undici-fetch errors on Node.js + // Trick for @whatwg-node/fetch errors on Node.js // TODO: This needs a better solution if ( e instanceof Error && diff --git a/packages/common/src/server.ts b/packages/common/src/server.ts index 8fe1d4f22a..f20640a6bc 100644 --- a/packages/common/src/server.ts +++ b/packages/common/src/server.ts @@ -31,7 +31,7 @@ import { RequestParser, ResultProcessor, } from './plugins/types.js' -import * as crossUndiciFetch from 'cross-undici-fetch' +import * as crossUndiciFetch from '@whatwg-node/fetch' import { processRequest as processGraphQLParams } from './processRequest.js' import { defaultYogaLogger, titleBold, YogaLogger } from './logger.js' import { CORSPluginOptions, useCORS } from './plugins/useCORS.js' diff --git a/packages/common/src/types.ts b/packages/common/src/types.ts index f571359cc9..ee6ce5414f 100644 --- a/packages/common/src/types.ts +++ b/packages/common/src/types.ts @@ -116,25 +116,25 @@ export type FetchEvent = Event & { export type FetchAPI = { /** * WHATWG compliant Request object constructor - * Default: `Request` from `cross-undici-fetch` + * Default: `Request` from `@whatwg-node/fetch` * @see https://developer.mozilla.org/en-US/docs/Web/API/Request */ Request: typeof Request /** * WHATWG compliant Response object constructor - * Default: `Response` from `cross-undici-fetch` + * Default: `Response` from `@whatwg-node/fetch` * @see https://developer.mozilla.org/en-US/docs/Web/API/Response */ Response: typeof Response /** * WHATWG compliant fetch function - * Default: `fetch` from `cross-undici-fetch` + * Default: `fetch` from `@whatwg-node/fetch` * @see https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch */ fetch: typeof fetch /** * WHATWG compliant ReadableStream object constructor - * Default: `ReadableStream` from `cross-undici-fetch` + * Default: `ReadableStream` from `@whatwg-node/fetch` * @see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream */ ReadableStream: typeof ReadableStream diff --git a/packages/event-target/redis-event-target/package.json b/packages/event-target/redis-event-target/package.json index 6a781d8950..043ce43d8d 100644 --- a/packages/event-target/redis-event-target/package.json +++ b/packages/event-target/redis-event-target/package.json @@ -27,7 +27,7 @@ "devDependencies": { "@types/ioredis-mock": "5.6.0", "event-target-polyfill": "0.0.3", - "ioredis": "5.2.1", + "ioredis": "5.2.2", "ioredis-mock": "8.2.2" }, "type": "module", diff --git a/packages/graphiql/index.html b/packages/graphiql/index.html index 1a8691044b..fbb697ec93 100644 --- a/packages/graphiql/index.html +++ b/packages/graphiql/index.html @@ -21,7 +21,9 @@ diff --git a/packages/graphiql/package.json b/packages/graphiql/package.json index 23d28a0a2e..172247eac3 100644 --- a/packages/graphiql/package.json +++ b/packages/graphiql/package.json @@ -25,18 +25,18 @@ "devDependencies": { "@types/react": "17.0.39", "@vitejs/plugin-react": "1.3.2", - "vite": "2.9.14" + "vite": "3.0.2" }, "dependencies": { - "@graphql-tools/url-loader": "^7.11.0", - "copy-to-clipboard": "^3.3.1", - "graphiql": "^1.8.8", - "graphiql-explorer": "^0.9.0", - "graphql": "^16.3.0", + "@graphql-tools/url-loader": "7.13.0", + "copy-to-clipboard": "3.3.1", + "graphiql": "1.8.8", + "graphiql-explorer": "0.9.0", + "graphql": "16.3.0", "react": "17.0.2", "react-dom": "17.0.2", - "use-url-search-params": "^2.5.1", - "json-bigint-patch": "^0.0.8" + "use-url-search-params": "2.5.1", + "json-bigint-patch": "0.0.8" }, "main": "dist/yoga-graphiql.umd.js", "module": "dist/yoga-graphiql.es.js", diff --git a/packages/graphiql/src/YogaGraphiQL.tsx b/packages/graphiql/src/YogaGraphiQL.tsx index 0263446771..26ccd044e4 100644 --- a/packages/graphiql/src/YogaGraphiQL.tsx +++ b/packages/graphiql/src/YogaGraphiQL.tsx @@ -23,7 +23,7 @@ import 'json-bigint-patch' const getOperationWithFragments = ( document: DocumentNode, - operationName: string, + operationName?: string, ): DocumentNode => { const definitions = document.definitions.filter((definition) => { if ( @@ -121,12 +121,11 @@ export function YogaGraphiQL(props: YogaGraphiQLProps): React.ReactElement { return function fetcher(graphQLParams: FetcherParams, opts?: FetcherOpts) { const document = getOperationWithFragments( parse(graphQLParams.query), - graphQLParams.operationName, + graphQLParams.operationName ?? undefined, ) - return executor({ document, - operationName: graphQLParams.operationName, + operationName: graphQLParams.operationName ?? undefined, variables: graphQLParams.variables, extensions: { headers: opts?.headers, diff --git a/packages/graphiql/vite.config.ts b/packages/graphiql/vite.config.ts index a029a276d2..5e5fb964db 100644 --- a/packages/graphiql/vite.config.ts +++ b/packages/graphiql/vite.config.ts @@ -11,6 +11,9 @@ export default defineConfig({ '/graphql': 'http://localhost:4000', }, }, + define: { + 'process.env.NODE_ENV': '"production"', + }, build: { lib: { entry: path.resolve(__dirname, 'src', 'bundle.tsx'), @@ -20,6 +23,7 @@ export default defineConfig({ rollupOptions: { output: { /** prevent code-splitting */ + inlineDynamicImports: false, manualChunks: () => '_.js', }, }, diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index 72c994f826..9ad4ec85a6 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -286,7 +286,7 @@ 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' + import { create } from '@whatwg-node/fetch' createServer({ fetchAPI: create({ useNodeFetch: false }), diff --git a/packages/node/__tests__/integration.spec.ts b/packages/node/__tests__/integration.spec.ts index 1d0c0b3ce2..82a36c0217 100644 --- a/packages/node/__tests__/integration.spec.ts +++ b/packages/node/__tests__/integration.spec.ts @@ -15,7 +15,7 @@ import 'json-bigint-patch' import http from 'http' import { useLiveQuery } from '@envelop/live-query' import { InMemoryLiveQueryStore } from '@n1ru4l/in-memory-live-query-store' -import { AbortController, fetch, File, FormData } from 'cross-undici-fetch' +import { AbortController, fetch, File, FormData } from '@whatwg-node/fetch' import { Plugin } from '@graphql-yoga/common' import { ExecutionResult } from '@graphql-tools/utils' diff --git a/packages/node/package.json b/packages/node/package.json index af83152dbf..63051c175f 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -67,7 +67,7 @@ "@graphql-tools/utils": "^8.8.0", "@graphql-yoga/common": "^2.12.3", "@graphql-yoga/subscription": "^2.2.2", - "cross-undici-fetch": "^0.4.13", + "@whatwg-node/fetch": "^0.0.2", "tslib": "^2.3.1" }, "devDependencies": { diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index 8a276a530f..ff1cbb5d5a 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -10,7 +10,7 @@ import { getNodeRequest, NodeRequest, sendNodeResponse } from './http-utils.js' import { YogaServer } from '@graphql-yoga/common' import type { YogaNodeServerOptions, AddressInfo } from './types.js' import { platform, release } from 'os' -import { create } from 'cross-undici-fetch' +import { createFetch } from '@whatwg-node/fetch' class YogaNodeServer< TServerContext extends Record, @@ -35,7 +35,7 @@ class YogaNodeServer< multipart: options?.multipart !== false, fetchAPI: options?.fetchAPI ?? - create({ + createFetch({ useNodeFetch: true, formDataLimits: typeof options?.multipart === 'object' diff --git a/packages/node/src/types.ts b/packages/node/src/types.ts index 023eec06cc..75c0dcce1a 100644 --- a/packages/node/src/types.ts +++ b/packages/node/src/types.ts @@ -1,5 +1,5 @@ import type { YogaServerOptions } from '@graphql-yoga/common' -import type { FormDataLimits } from 'cross-undici-fetch' +import type { FormDataLimits } from '@whatwg-node/fetch' import type { ServerOptions as HttpsServerOptions } from 'https' /** diff --git a/packages/render-graphiql/scripts/yoga-bundle-string.mjs b/packages/render-graphiql/scripts/yoga-bundle-string.mjs index 95289412b7..194b2ac272 100644 --- a/packages/render-graphiql/scripts/yoga-bundle-string.mjs +++ b/packages/render-graphiql/scripts/yoga-bundle-string.mjs @@ -4,7 +4,7 @@ import { fileURLToPath } from 'url' const directoryName = path.dirname(fileURLToPath(import.meta.url)) const inputPath = path.resolve(directoryName, '..', '..', 'graphiql', 'dist') -const jsFile = path.resolve(inputPath, 'yoga-graphiql.es.js') +const jsFile = path.resolve(inputPath, 'yoga-graphiql.umd.js') const cssFile = path.resolve(inputPath, 'style.css') const outFile = path.resolve(directoryName, '..', 'src', 'graphiql.ts') diff --git a/packages/render-graphiql/src/index.ts b/packages/render-graphiql/src/index.ts index fa2aca3a9d..9db0daa4bc 100644 --- a/packages/render-graphiql/src/index.ts +++ b/packages/render-graphiql/src/index.ts @@ -16,9 +16,9 @@ export const renderGraphiQL = (opts?: GraphiQLOptions) => /* HTML */ `
-