From 625e934e2e552678691c33730e9797ab8f95b7c7 Mon Sep 17 00:00:00 2001 From: Flacial Date: Fri, 16 Dec 2022 19:10:10 +0400 Subject: [PATCH 1/4] feat: Add removed column to Exercise table --- graphql/index.tsx | 6 ++++++ graphql/typeDefs.ts | 1 + .../migration.sql | 2 ++ prisma/schema.prisma | 2 +- 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 prisma/migrations/20221216150853_add_removed_column_to_exercise/migration.sql diff --git a/graphql/index.tsx b/graphql/index.tsx index 67edc4e65..979bf7b1e 100644 --- a/graphql/index.tsx +++ b/graphql/index.tsx @@ -85,6 +85,7 @@ export type Exercise = { flaggedById?: Maybe id: Scalars['Int'] module: Module + removed?: Maybe testStr?: Maybe } @@ -1000,6 +1001,7 @@ export type GetExercisesQuery = { exercises: Array<{ __typename?: 'Exercise' id: number + removed?: boolean | null description: string answer: string explanation?: string | null @@ -1723,6 +1725,7 @@ export type ExerciseResolvers< flaggedById?: Resolver, ParentType, ContextType> id?: Resolver module?: Resolver + removed?: Resolver, ParentType, ContextType> testStr?: Resolver, ParentType, ContextType> __isTypeOf?: IsTypeOfResolverFn }> @@ -4324,6 +4327,7 @@ export const GetExercisesDocument = gql` slug } } + removed description answer explanation @@ -6427,6 +6431,7 @@ export type ExerciseKeySpecifier = ( | 'flaggedById' | 'id' | 'module' + | 'removed' | 'testStr' | ExerciseKeySpecifier )[] @@ -6441,6 +6446,7 @@ export type ExerciseFieldPolicy = { flaggedById?: FieldPolicy | FieldReadFunction id?: FieldPolicy | FieldReadFunction module?: FieldPolicy | FieldReadFunction + removed?: FieldPolicy | FieldReadFunction testStr?: FieldPolicy | FieldReadFunction } export type ExerciseCommentKeySpecifier = ( diff --git a/graphql/typeDefs.ts b/graphql/typeDefs.ts index 3eb66c47f..844e755e1 100644 --- a/graphql/typeDefs.ts +++ b/graphql/typeDefs.ts @@ -276,6 +276,7 @@ export default gql` answer: String! testStr: String explanation: String + removed: Boolean flaggedAt: String flagReason: String flaggedBy: User diff --git a/prisma/migrations/20221216150853_add_removed_column_to_exercise/migration.sql b/prisma/migrations/20221216150853_add_removed_column_to_exercise/migration.sql new file mode 100644 index 000000000..37ce3c0ce --- /dev/null +++ b/prisma/migrations/20221216150853_add_removed_column_to_exercise/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "exercises" ADD COLUMN "removed" BOOLEAN DEFAULT false; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a4167003f..2e7d5ea1d 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -187,6 +187,7 @@ model Exercise { answer String testStr String? explanation String? + removed Boolean? @default(false) flagReason String? flaggedAt DateTime? flaggedById Int? @@ -223,5 +224,4 @@ model ExerciseComment { author User @relation(fields: [authorId], references: [id], onDelete: SetNull) parent ExerciseComment? @relation("ExerciseCommentReplies", fields: [parentId], references: [id]) replies ExerciseComment[] @relation("ExerciseCommentReplies") - } From c37bbf5ae09af80c29033c085f5f29429dc0cea8 Mon Sep 17 00:00:00 2001 From: Flacial Date: Fri, 16 Dec 2022 19:11:17 +0400 Subject: [PATCH 2/4] Update getExercises query & mock data --- __dummy__/getExercisesData.ts | 3 +++ graphql/queries/getExercises.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/__dummy__/getExercisesData.ts b/__dummy__/getExercisesData.ts index 1735c3393..065b8ed54 100644 --- a/__dummy__/getExercisesData.ts +++ b/__dummy__/getExercisesData.ts @@ -70,6 +70,7 @@ const getExercisesData: GetExercisesQuery = { email: 'noob@c0d3.com', discordId: '8321' }, + removed: false, description: '```\nlet a = 5\na = a + 10\n// what is a?\n```', answer: '15', explanation: 'You can reassign variables that were created with "let".', @@ -90,6 +91,7 @@ const getExercisesData: GetExercisesQuery = { email: 'noob@c0d3.com', discordId: '8321' }, + removed: false, description: '```\nlet a = 1\na += 2\n// what is a?\n```', answer: '3', explanation: '`a += 2` is a shorter way to write `a = a + 2`', @@ -110,6 +112,7 @@ const getExercisesData: GetExercisesQuery = { email: 'noob@c0d3.com', discordId: '8321' }, + removed: false, description: '```\nlet a = 1\na -= 2\n// what is a?\n```', answer: '-1', explanation: null, diff --git a/graphql/queries/getExercises.ts b/graphql/queries/getExercises.ts index 4a73b1d33..6187ca990 100644 --- a/graphql/queries/getExercises.ts +++ b/graphql/queries/getExercises.ts @@ -28,6 +28,7 @@ const GET_EXERCISES = gql` slug } } + removed description answer explanation From 56221530b3339ff75d8c0c8e54626dac6c527c7e Mon Sep 17 00:00:00 2001 From: Flacial Date: Fri, 16 Dec 2022 19:23:37 +0400 Subject: [PATCH 3/4] Revert "build(deps-dev): Bump typescript from 4.7.4 to 4.9.4" This reverts commit 946378ed30953e07ec4ce23195218eeab2276152. --- package.json | 4 ++-- yarn.lock | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 90bb4cafe..d1b5d2060 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "test": "cross-env TZ=UTC jest --coverage --runInBand", "ts-node": "ts-node --compiler-options {\\\"module\\\":\\\"CommonJS\\\"}", "type-check": "tsc", - "generate": "graphql-codegen --config codegen.yml && node scripts/ignoreCodegenIndex.js", + "generate": "graphql-codegen --config codegen.yml", "postinstall": "node scripts/prismaUtils.js setup && prisma generate", "prepare": "husky install", "vercel-build": "node scripts/prismaUtils.js migrate && next build" @@ -129,6 +129,6 @@ "storybook-addon-next-router": "^4.0.2", "svgo": "^3.0.2", "ts-node": "^10.9.1", - "typescript": "^4.9.4" + "typescript": "^4.7.4" } } diff --git a/yarn.lock b/yarn.lock index c06f96a7e..c9234d672 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17427,10 +17427,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^4.9.4: - version "4.9.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.4.tgz#a2a3d2756c079abda241d75f149df9d561091e78" - integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg== +typescript@^4.7.4: + version "4.7.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235" + integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== ua-parser-js@^0.7.18: version "0.7.28" From 5f6fe7c4abe43c167619d79dd8443ef97194c924 Mon Sep 17 00:00:00 2001 From: Flacial Date: Fri, 16 Dec 2022 19:23:42 +0400 Subject: [PATCH 4/4] Revert "Add script to ignore graphql/index.tsx" This reverts commit beb243bb10e78016bfb4360ea35f1918a5f1588b. --- scripts/ignoreCodegenIndex.js | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 scripts/ignoreCodegenIndex.js diff --git a/scripts/ignoreCodegenIndex.js b/scripts/ignoreCodegenIndex.js deleted file mode 100644 index 743d1fe55..000000000 --- a/scripts/ignoreCodegenIndex.js +++ /dev/null @@ -1,11 +0,0 @@ -const fs = require('fs') - -fs.readFile('./graphql/index.tsx', 'utf-8', (err, data) => { - if (err) throw new Error('Failed to read graphql/index.tsx') - - const newData = '// @ts-nocheck\n' + data - - fs.writeFile('./graphql/index.tsx', newData, (err, data) => { - if (err) throw new Error('Failed to ignore graphql/index.tsx content') - }) -})