Skip to content

Commit

Permalink
Use / for paths in generated code on Windows
Browse files Browse the repository at this point in the history
Fixes #128
  • Loading branch information
captbaritone committed Mar 23, 2024
1 parent 6f80cd0 commit 8bd20c0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/codegen.ts
Expand Up @@ -25,7 +25,7 @@ import {
isUnionType,
} from "graphql";
import * as ts from "typescript";
import * as path from "path";
import * as path from "node:path";
import {
FIELD_METADATA_DIRECTIVE,
parseFieldMetadataDirective,
Expand Down Expand Up @@ -239,7 +239,9 @@ class Codegen {
parentTypeName,
funcName,
);
this.import(`./${relative}`, [{ name: funcName, as: resolverName }]);
this.import(`./${normalizeRelativePathToPosix(relative)}`, [
{ name: funcName, as: resolverName },
]);

const usedArgs = RESOLVER_ARGS.slice(0, argCount);

Expand Down Expand Up @@ -882,3 +884,8 @@ function formatResolverFunctionVarName(
const field = fieldName[0].toUpperCase() + fieldName.slice(1);
return `${parent}${field}Resolver`;
}

// https://github.com/sindresorhus/slash/blob/98b618f5a3bfcb5dd374b204868818845b87bb2f/index.js#L8C9-L8C33
function normalizeRelativePathToPosix(unknownPath: string): string {
return unknownPath.replace(/\\/g, "/");
}

0 comments on commit 8bd20c0

Please sign in to comment.