Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ permissions:

jobs:
test:
runs-on: ubuntu-latest
name: test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand Down
11 changes: 9 additions & 2 deletions tests/codegen.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ test("generated types have no type errors when a query uses enums and input obje
fs.mkdirSync(path.join(dir, "src"));
fs.writeFileSync(path.join(dir, "src", "run.graphql"), inputQuery);
// Codegen resolves its plugins from the function directory, as in an installed function.
fs.symlinkSync(path.join(root, "node_modules"), path.join(dir, "node_modules"), "dir");
// A junction on Windows, which needs no extra privileges; the type is ignored elsewhere.
fs.symlinkSync(path.join(root, "node_modules"), path.join(dir, "node_modules"), "junction");

const configPath = path.join(configDir, "codegen.json");
fs.writeFileSync(
Expand All @@ -105,7 +106,13 @@ test("generated types have no type errors when a query uses enums and input obje
config: { ...cliDefaults, ...templateCodegen.config, scalars: cliDefaults.scalars },
}),
);
const bin = fs.realpathSync(path.join(root, "node_modules", ".bin", "graphql-code-generator"));
// Resolve the bin script from the package itself: on Windows, node_modules/.bin
// holds shell and cmd shims rather than symlinks to the JavaScript entry point.
const cliPackageJson = require.resolve("@graphql-codegen/cli/package.json");
const bin = path.join(
path.dirname(cliPackageJson),
require(cliPackageJson).bin["graphql-code-generator"],
);
execFileSync(process.execPath, [bin, "--config", configPath], { cwd: dir, stdio: "pipe" });

const program = ts.createProgram([path.join(dir, "generated", "api.ts")], {
Expand Down
Loading