Skip to content

Commit 277b73c

Browse files
authored
Set scalar types for codegen (#93)
1 parent eba6810 commit 277b73c

2 files changed

Lines changed: 30 additions & 13 deletions

File tree

src/fs.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { promises as fs } from "fs";
22
import * as path from "path";
3-
import type { FileAddition } from "./github/graphql/generated/types.ts";
43
import type {
4+
CommitFilesFromBuffersArgs,
55
CommitFilesFromDirectoryArgs,
66
CommitFilesResult,
77
} from "./interface.ts";
@@ -12,14 +12,15 @@ export const commitFilesFromDirectory = async ({
1212
fileChanges,
1313
...otherArgs
1414
}: CommitFilesFromDirectoryArgs): Promise<CommitFilesResult> => {
15-
const additions: FileAddition[] = await Promise.all(
16-
(fileChanges.additions || []).map(async (p) => {
17-
return {
18-
path: p,
19-
contents: await fs.readFile(path.join(cwd, p)),
20-
};
21-
}),
22-
);
15+
const additions: CommitFilesFromBuffersArgs["fileChanges"]["additions"] =
16+
await Promise.all(
17+
(fileChanges.additions || []).map(async (p) => {
18+
return {
19+
path: p,
20+
contents: await fs.readFile(path.join(cwd, p)),
21+
};
22+
}),
23+
);
2324

2425
return commitFilesFromBuffers({
2526
...otherArgs,

src/github/codegen.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,39 @@ if (process.env.CI || !fs.existsSync(schemaPath)) {
1717
fs.writeFileSync(schemaPath, await result.text());
1818
}
1919

20+
const scalars = {
21+
Base64String: "string",
22+
BigInt: "string",
23+
CustomPropertyValue: "string",
24+
Date: "string",
25+
DateTime: "string",
26+
GitObjectID: "string",
27+
GitRefname: "string",
28+
GitSSHRemote: "string",
29+
GitTimestamp: "string",
30+
HTML: "string",
31+
PreciseDateTime: "string",
32+
URI: "string",
33+
X509Certificate: "string",
34+
};
35+
2036
const config: CodegenConfig = {
2137
schema: schemaPath,
2238
documents: ["src/github/graphql/queries.ts"],
2339
generates: {
2440
"src/github/graphql/generated/types.ts": {
2541
plugins: ["typescript"],
2642
config: {
27-
// TODO: Look into adding stricter types or use `unknown`
28-
defaultScalarType: "any",
43+
scalars,
44+
strictScalars: true,
2945
enumsAsTypes: true,
3046
},
3147
},
3248
"src/github/graphql/generated/operations.ts": {
3349
plugins: ["typescript-operations"],
3450
config: {
35-
// TODO: Look into adding stricter types or use `unknown`
36-
defaultScalarType: "any",
51+
scalars,
52+
strictScalars: true,
3753
importSchemaTypesFrom: "src/github/graphql/generated/types.ts",
3854
importExtension: ".ts",
3955
},

0 commit comments

Comments
 (0)