Skip to content

Commit 8916fcd

Browse files
author
unknown
committed
refactor(codegen): rename localhostAdapter to nodeHttpAdapter
1 parent d1e9982 commit 8916fcd

3 files changed

Lines changed: 16 additions & 13 deletions

File tree

graphql/codegen/src/core/codegen/cli/executor-generator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ function createImportDeclaration(
3232

3333
export interface ExecutorOptions {
3434
/** Enable NodeHttpAdapter for *.localhost subdomain routing */
35-
localhostAdapter?: boolean;
35+
nodeHttpAdapter?: boolean;
3636
}
3737

3838
export function generateExecutorFile(toolName: string, options?: ExecutorOptions): GeneratedFile {
3939
const statements: t.Statement[] = [];
4040

4141
// Import NodeHttpAdapter for *.localhost subdomain routing
42-
if (options?.localhostAdapter) {
42+
if (options?.nodeHttpAdapter) {
4343
statements.push(
4444
createImportDeclaration('./node-fetch', ['NodeHttpAdapter']),
4545
);
@@ -204,7 +204,7 @@ export function generateExecutorFile(toolName: string, options?: ExecutorOptions
204204
),
205205

206206
// Build createClient config — use NodeHttpAdapter for *.localhost endpoints
207-
...(options?.localhostAdapter
207+
...(options?.nodeHttpAdapter
208208
? [
209209
t.returnStatement(
210210
t.callExpression(t.identifier('createClient'), [
@@ -262,7 +262,7 @@ export function generateMultiTargetExecutorFile(
262262
const statements: t.Statement[] = [];
263263

264264
// Import NodeHttpAdapter for *.localhost subdomain routing
265-
if (options?.localhostAdapter) {
265+
if (options?.nodeHttpAdapter) {
266266
statements.push(
267267
createImportDeclaration('./node-fetch', ['NodeHttpAdapter']),
268268
);
@@ -515,7 +515,7 @@ export function generateMultiTargetExecutorFile(
515515
]),
516516
),
517517
// Build createClient config — use NodeHttpAdapter for *.localhost endpoints
518-
...(options?.localhostAdapter
518+
...(options?.nodeHttpAdapter
519519
? [
520520
t.returnStatement(
521521
t.callExpression(t.identifier('createFn'), [

graphql/codegen/src/core/codegen/cli/index.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,19 @@ export function generateCli(options: GenerateCliOptions): GenerateCliResult {
4545
? cliConfig.toolName
4646
: 'app';
4747

48-
const useLocalhostAdapter = typeof cliConfig === 'object' && !!cliConfig.localhostAdapter;
48+
const useNodeHttpAdapter =
49+
typeof cliConfig === 'object' && !!cliConfig.nodeHttpAdapter;
4950

50-
const executorFile = generateExecutorFile(toolName, { localhostAdapter: useLocalhostAdapter });
51+
const executorFile = generateExecutorFile(toolName, {
52+
nodeHttpAdapter: useNodeHttpAdapter,
53+
});
5154
files.push(executorFile);
5255

5356
const utilsFile = generateUtilsFile();
5457
files.push(utilsFile);
5558

5659
// Generate node HTTP adapter if configured (for *.localhost subdomain routing)
57-
if (useLocalhostAdapter) {
60+
if (useNodeHttpAdapter) {
5861
files.push(generateNodeFetchFile());
5962
}
6063

@@ -118,8 +121,8 @@ export interface GenerateMultiTargetCliOptions {
118121
toolName: string;
119122
builtinNames?: BuiltinNames;
120123
targets: MultiTargetCliTarget[];
121-
/** Enable localhost fetch adapter for *.localhost subdomain routing */
122-
localhostAdapter?: boolean;
124+
/** Enable NodeHttpAdapter for *.localhost subdomain routing */
125+
nodeHttpAdapter?: boolean;
123126
}
124127

125128
export function resolveBuiltinNames(
@@ -154,15 +157,15 @@ export function generateMultiTargetCli(
154157
ormImportPath: t.ormImportPath,
155158
}));
156159
const executorFile = generateMultiTargetExecutorFile(toolName, executorInputs, {
157-
localhostAdapter: !!options.localhostAdapter,
160+
nodeHttpAdapter: !!options.nodeHttpAdapter,
158161
});
159162
files.push(executorFile);
160163

161164
const utilsFile = generateUtilsFile();
162165
files.push(utilsFile);
163166

164167
// Generate node HTTP adapter if configured (for *.localhost subdomain routing)
165-
if (options.localhostAdapter) {
168+
if (options.nodeHttpAdapter) {
166169
files.push(generateNodeFetchFile());
167170
}
168171

graphql/codegen/src/types/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export interface CliConfig {
208208
* No global patching — the adapter is passed to createClient via the adapter option.
209209
* @default false
210210
*/
211-
localhostAdapter?: boolean;
211+
nodeHttpAdapter?: boolean;
212212
}
213213

214214
/**

0 commit comments

Comments
 (0)