Skip to content

Commit d7cd59e

Browse files
authored
Patch scraped GraphQL schema to mark some fields as non-null (#457)
Although LeetCode reports these fields as nullable, in practice they aren't. I verified this using: * the Zod types I've been writing by hand * fetching data for all the questions to see what data types we get
1 parent 5924349 commit d7cd59e

File tree

42 files changed

+12511
-811
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+12511
-811
lines changed

workspaces/adventure-pack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"@code-chronicles/eslint-config": "workspace:*",
7070
"@code-chronicles/util": "workspace:*",
7171
"@jest/globals": "29.7.0",
72-
"@types/node": "22.7.4",
72+
"@types/node": "22.7.5",
7373
"@types/react": "18.3.11",
7474
"@types/react-dom": "18.3.0",
7575
"@types/react-syntax-highlighter": "15.5.13",

workspaces/download-leetcode-submissions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"devDependencies": {
3131
"@code-chronicles/eslint-config": "workspace:*",
3232
"@code-chronicles/webpack-make-output-executable-plugin": "workspace:*",
33-
"@types/node": "22.7.4",
33+
"@types/node": "22.7.5",
3434
"cross-env": "7.0.3",
3535
"eslint": "9.12.0",
3636
"fork-ts-checker-webpack-plugin": "9.0.2",

workspaces/eslint-config/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"dependencies": {
2424
"@stylistic/eslint-plugin-js": "2.9.0",
2525
"@stylistic/eslint-plugin-ts": "2.9.0",
26-
"@typescript-eslint/eslint-plugin": "8.5.0",
27-
"@typescript-eslint/parser": "8.5.0",
26+
"@typescript-eslint/eslint-plugin": "8.8.1",
27+
"@typescript-eslint/parser": "8.8.1",
2828
"eslint-import-resolver-typescript": "3.6.3",
2929
"eslint-plugin-import": "2.31.0",
3030
"eslint-plugin-import-x": "4.3.1",

workspaces/fetch-leetcode-problem-list/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"devDependencies": {
2929
"@code-chronicles/eslint-config": "workspace:*",
3030
"@code-chronicles/webpack-make-output-executable-plugin": "workspace:*",
31-
"@types/node": "22.7.4",
31+
"@types/node": "22.7.5",
3232
"cross-env": "7.0.3",
3333
"eslint": "9.12.0",
3434
"fork-ts-checker-webpack-plugin": "9.0.2",

workspaces/fetch-recent-accepted-leetcode-submissions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"devDependencies": {
2929
"@code-chronicles/eslint-config": "workspace:*",
3030
"@code-chronicles/webpack-make-output-executable-plugin": "workspace:*",
31-
"@types/node": "22.7.4",
31+
"@types/node": "22.7.5",
3232
"cross-env": "7.0.3",
3333
"eslint": "9.12.0",
3434
"fork-ts-checker-webpack-plugin": "9.0.2",

workspaces/generate-health-report/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"devDependencies": {
2828
"@code-chronicles/eslint-config": "workspace:*",
29-
"@types/node": "22.7.4",
29+
"@types/node": "22.7.5",
3030
"eslint": "9.12.0",
3131
"prettier": "3.3.3",
3232
"typescript": "5.6.2"

workspaces/generate-health-report/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const COMMANDS = [
1414
"yarn workspace @code-chronicles/adventure-pack build-chrome-extension",
1515
"yarn workspace @code-chronicles/fetch-leetcode-problem-list build",
1616
"yarn workspace @code-chronicles/fetch-recent-accepted-leetcode-submissions build",
17+
"yarn workspace @code-chronicles/leetcode-api codegen",
1718
"yarn workspace @code-chronicles/leetcode-zen-mode build",
1819
"yarn workspace @code-chronicles/post-leetcode-potd-to-discord build",
1920
];

workspaces/javascript-leetcode-month/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@code-chronicles/eslint-config": "workspace:*",
2424
"@code-chronicles/util": "workspace:*",
2525
"@types/mdast": "4.0.4",
26-
"@types/node": "22.7.4",
26+
"@types/node": "22.7.5",
2727
"eslint": "9.12.0",
2828
"mdast": "3.0.0",
2929
"prettier": "3.3.3",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
schema.graphql linguist-generated
1+
schema-*.graphql linguist-generated
22
*.generated.ts linguist-generated

workspaces/leetcode-api/graphql-codegen.config.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@ import type { CodegenConfig } from "@graphql-codegen/cli";
22
import type { Types as GraphQLCodegen } from "@graphql-codegen/plugin-helpers";
33
import immutableUpdate from "immutability-helper";
44

5+
import { SCHEMA_PATCHED_FILE } from "./src/scripts/scrape-graphql-schema/constants.ts";
6+
57
const commonTypeScriptPluginConfig: GraphQLCodegen.PluginConfig = {
68
arrayInputCoercion: false,
79
enumsAsTypes: true,
810
defaultScalarType: "unknown",
911
skipTypename: true,
1012
useTypeImports: true,
1113

14+
scalars: {
15+
DateTime: {
16+
input: "unknown",
17+
output: "string",
18+
},
19+
JSONString: {
20+
input: "unknown",
21+
output: "string",
22+
},
23+
},
24+
1225
// TODO: add strictScalars: true
1326
};
1427

@@ -45,7 +58,7 @@ const nearOperationFilePreset: GraphQLCodegen.ConfiguredOutput = {
4558
};
4659

4760
const config: CodegenConfig = {
48-
schema: "schema.graphql",
61+
schema: SCHEMA_PATCHED_FILE,
4962
documents: ["src/api/**/query.graphql"],
5063
overwrite: true,
5164
emitLegacyCommonJSImports: false,

0 commit comments

Comments
 (0)