Skip to content

Commit b2b23cc

Browse files
committed
Use Fetch ponyfill in Node 18 to avoid issues with new global fetch
It's likely that some of these are just differences, rather than real problems, but there's little downside in sticking with the ponyfill for now (since we need it for older Node anyway) and it should let us get everything working properly to fully support Node v18 which would be great.
1 parent 73e24d6 commit b2b23cc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/client/admin-client.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { print } from 'graphql';
1111
import { DEFAULT_ADMIN_SERVER_PORT } from "../types";
1212

1313
import { MaybePromise, RequireProps } from '../util/type-utils';
14+
import { isNode } from '../util/util';
1415
import { isErrorLike } from '../util/error';
1516
import { getDeferred } from '../util/promise';
1617

@@ -21,7 +22,9 @@ import { SchemaIntrospector } from './schema-introspection';
2122
import { AdminQuery, getSingleSelectedFieldName } from './admin-query';
2223
import { MockttpOptions } from '../mockttp';
2324

24-
const { fetch, Headers } = typeof globalThis.fetch === 'undefined' ? CrossFetch : globalThis;
25+
const { fetch, Headers } = isNode || typeof globalThis.fetch === 'undefined'
26+
? CrossFetch
27+
: globalThis;
2528

2629
export class ConnectionError extends TypedError { }
2730

0 commit comments

Comments
 (0)