File tree Expand file tree Collapse file tree 8 files changed +14121
-145
lines changed Expand file tree Collapse file tree 8 files changed +14121
-145
lines changed Original file line number Diff line number Diff line change 1+ import { CodegenConfig } from "@graphql-codegen/cli" ;
2+
3+ const config : CodegenConfig = {
4+ schema : "schema.graphql" ,
5+ documents : [ "src/**/*" ] ,
6+ generates : {
7+ "./src/generated/client.ts" : {
8+ plugins : [
9+ "typescript" ,
10+ "typescript-operations" ,
11+ "typescript-graphql-request" ,
12+ ] ,
13+ config : {
14+ gqlImport : "graphql-request#gql" ,
15+ } ,
16+ } ,
17+ } ,
18+ emitLegacyCommonJSImports : false ,
19+ } ;
20+
21+ export default config ;
Original file line number Diff line number Diff line change 1515 "type" : " module" ,
1616 "exports" : " ./src/main.ts" ,
1717 "scripts" : {
18+ "codegen" : " graphql-codegen-esm --config graphql-codegen.ts" ,
1819 "format" : " prettier --color --write ." ,
1920 "lint" : " eslint --color --max-warnings=0 ." ,
2021 "scrape-graphql-schema" : " tsx src/scripts/scrape-graphql-schema/main.ts" ,
3132 },
3233 "devDependencies" : {
3334 "@code-chronicles/eslint-config" : " workspace:*" ,
35+ "@graphql-codegen/cli" : " 5.0.2" ,
36+ "@graphql-codegen/typescript-graphql-request" : " 6.2.0" ,
3437 "@types/node" : " 22.7.4" ,
3538 "eslint" : " 9.11.1" ,
3639 "graphql" : " 16.9.0" ,
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import { questionDifficultyZodType } from "./zod-types/questionDifficultyZodType
1111import { questionTitleSlugZodType } from "./zod-types/questionTitleSlugZodType.ts" ;
1212
1313const QUERY = gql `
14- query {
14+ query fetchActiveDailyCodingChallengeQuestion {
1515 activeDailyCodingChallengeQuestion {
1616 date
1717 question {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { getGraphQLClient } from "./getGraphQLClient.ts";
66// TODO: see if there are any fun GraphQL ESLint plugins
77
88const QUERY = gql `
9- query ($topicId: Int!) {
9+ query fetchTopic ($topicId: Int!) {
1010 topic(id: $topicId) {
1111 title
1212 solutionTags {
Original file line number Diff line number Diff line change @@ -4,11 +4,12 @@ import { z } from "zod";
44import { numericIdAsNumberZodType } from "@code-chronicles/util/numericIdAsNumberZodType" ;
55
66import { getGraphQLClient } from "./getGraphQLClient.ts" ;
7+ import { getSdk } from "./generated/client.ts" ;
78import { questionDifficultyZodType } from "./zod-types/questionDifficultyZodType.ts" ;
89import { questionTitleSlugZodType } from "./zod-types/questionTitleSlugZodType.ts" ;
910
10- const QUERY = gql `
11- query (
11+ gql `
12+ query fetchQuestionList (
1213 $categorySlug: String!
1314 $limit: Int
1415 $skip: Int
@@ -79,7 +80,7 @@ export async function fetchQuestionList({
7980 limit ?: number ;
8081 skip ?: number ;
8182} = { } ) : Promise < QuestionList > {
82- const data = await getGraphQLClient ( ) . request ( QUERY , {
83+ const data = await getSdk ( getGraphQLClient ( ) ) . fetchQuestionList ( {
8384 categorySlug,
8485 filters,
8586 limit,
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { getGraphQLClient } from "./getGraphQLClient.ts";
77import { questionTitleSlugZodType } from "./zod-types/questionTitleSlugZodType.ts" ;
88
99const QUERY = gql `
10- query ($username: String!, $limit: Int!) {
10+ query fetchRecentAcSubmissionList ($username: String!, $limit: Int!) {
1111 recentAcSubmissionList(username: $username, limit: $limit) {
1212 id
1313 title
You can’t perform that action at this time.
0 commit comments