Skip to content

Commit e6281f3

Browse files
committed
fix: codegen files
1 parent 6daa2f9 commit e6281f3

File tree

10 files changed

+156
-80
lines changed

10 files changed

+156
-80
lines changed

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"printWidth": 100,
6+
"trailingComma": "all"
7+
}

apps/book-server/.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"printWidth": 100,
6+
"trailingComma": "all"
7+
}

apps/book-server/scripts/createMock.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ class Seeder {
2323
}
2424

2525
async createBook(writer: Writer) {
26-
const mockPages = getMockPages(100).map((page) => ({ writer_id: writer.id, ...page }))
26+
const mockPages = getMockPages(100).map((page) => ({
27+
writer_id: writer.id,
28+
...page,
29+
}))
2730
const book = await this.mongo.book.create({
2831
data: {
2932
writer_id: writer.id,

apps/book-server/src/common/plugins/global/mercuriusPlugin.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ const mercuriusPlugin: FastifyPluginAsync = async (fastify) => {
4040
code,
4141
statusCode,
4242
stack,
43-
errors: errors?.map((error) => ({ name: error.name, message: error.message })),
43+
errors: errors?.map((error) => ({
44+
name: error.name,
45+
message: error.message,
46+
})),
4447
}
4548
if (env.get('appEnv') === 'development') {
4649
console.log('errorHandler')

apps/book-server/src/graphql/helpers/generated.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,26 @@ import { GraphQLContext } from '../../common/interfaces/graphql.mjs'
55
import { Book as BookModel } from '@packages/database/velog-book-mongo'
66
export type Maybe<T> = T | null | undefined
77
export type InputMaybe<T> = T | undefined
8-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] }
9-
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> }
10-
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> }
8+
export type Exact<T extends { [key: string]: unknown }> = {
9+
[K in keyof T]: T[K]
10+
}
11+
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
12+
[SubKey in K]?: Maybe<T[SubKey]>
13+
}
14+
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
15+
[SubKey in K]: Maybe<T[SubKey]>
16+
}
1117
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = {
1218
[_ in K]?: never
1319
}
1420
export type Incremental<T> =
1521
| T
16-
| { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }
17-
export type RequireFields<T, K extends keyof T> = Omit<T, K> & { [P in K]-?: NonNullable<T[P]> }
22+
| {
23+
[P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never
24+
}
25+
export type RequireFields<T, K extends keyof T> = Omit<T, K> & {
26+
[P in K]-?: NonNullable<T[P]>
27+
}
1828
/** All built-in and custom scalars, mapped to their actual values */
1929
export type Scalars = {
2030
ID: { input: string; output: string }

apps/server/codegen.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const config: CodegenConfig = {
55
schema: 'src/graphql/**/*.gql',
66
documents: undefined,
77
hooks: {
8-
afterOneFileWrite: ['prettier --write'],
8+
afterOneFileWrite: ['pnpm lint'],
99
},
1010
generates: {
1111
'src/graphql/helpers/generated.ts': {
@@ -21,15 +21,15 @@ const config: CodegenConfig = {
2121
],
2222
config: {
2323
skipTypename: true,
24-
contextType: './../../common/interfaces/graphql#GraphQLContext',
24+
contextType: './../../common/interfaces/graphql.js#GraphQLContext',
2525
enumValues: {
26-
NotificationType: './enums#NotificationType',
26+
NotificationType: './enums.js#NotificationType',
2727
},
2828
mappers: {
29-
User: '@packages/database/src/velog-rds.mjs#User as UserModel',
30-
UserProfile: '@packages/database/src/velog-rds.mjs#UserProfile as UserProfileModel',
31-
Post: '@packages/database/src/velog-rds.mjs#Post as PostModel',
32-
Comment: '@packages/database/src/velog-rds.mjs#Comment as CommentModel',
29+
User: '@packages/database/velog-rds#User as UserModel',
30+
UserProfile: '@packages/database/velog-rds#UserProfile as UserProfileModel',
31+
Post: '@packages/database/velog-rds#Post as PostModel',
32+
Comment: '@packages/database/velog-rds#Comment as CommentModel',
3333
},
3434
inputMaybeValue: 'T | undefined',
3535
maybeValue: 'T | null | undefined',

apps/server/src/graphql/helpers/generated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/* eslint-disable @typescript-eslint/ban-types */
22
/* eslint-disable @typescript-eslint/no-unused-vars */
3+
import { NotificationType } from './enums.js'
34
import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql'
45
import {
56
User as UserModel,
67
UserProfile as UserProfileModel,
78
Post as PostModel,
89
Comment as CommentModel,
910
} from '@packages/database/velog-rds'
10-
import { NotificationType } from './enums.js'
11-
import { GraphQLContext } from '@interfaces/graphql.js'
11+
import { GraphQLContext } from './../../common/interfaces/graphql.js'
1212
export type Maybe<T> = T | null | undefined
1313
export type InputMaybe<T> = T | undefined
1414
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] }

apps/web/codegen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const config: CodegenConfig = {
66
schema: `${ENV.graphqlHost}/graphql`,
77
documents: 'src/graphql/*.gql',
88
hooks: {
9-
afterOneFileWrite: ['prettier --write'],
9+
afterOneFileWrite: ['pnpm lint'],
1010
},
1111
generates: {
1212
'src/graphql/helpers/generated.ts': {

packages/not-shared/scripts/checkGql.mts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ class Runner {
5858
fs.readdirSync(dirpath)
5959
.filter((file) => path.extname(file) === '.ts')
6060
.forEach((file) => {
61-
const text = fs.readFileSync(`${dirpath}/${file}`, { encoding: 'utf-8' })
61+
const text = fs.readFileSync(`${dirpath}/${file}`, {
62+
encoding: 'utf-8',
63+
})
6264
// gql 태그로 정의된 쿼리들만 추출
6365
const gqlQueries = text.match(/gql`([\s\S]*?)`/gm)
6466

@@ -88,7 +90,9 @@ class Runner {
8890
fs.readdirSync(dirpath)
8991
.filter((file) => path.extname(file) === '.gql')
9092
.forEach((file) => {
91-
const query = fs.readFileSync(`${dirpath}/${file}`, { encoding: 'utf-8' })
93+
const query = fs.readFileSync(`${dirpath}/${file}`, {
94+
encoding: 'utf-8',
95+
})
9296
const blocks = query.match(/{[^{}]+}/g)
9397
if (blocks) {
9498
blocks.forEach((block) => {
@@ -172,7 +176,9 @@ class Runner {
172176
fs.readdirSync(dirpath)
173177
.filter((file) => path.extname(file) === '.gql')
174178
.forEach((file) => {
175-
const query = fs.readFileSync(`${dirpath}/${file}`, { encoding: 'utf-8' })
179+
const query = fs.readFileSync(`${dirpath}/${file}`, {
180+
encoding: 'utf-8',
181+
})
176182
// 모든 type 정의 추출 (type Query와 type Mutation 제외)
177183
const typeDefs = query.match(/type\s+(?!Query|Mutation)(\w+)\s*{[^}]*}/g)
178184
if (typeDefs) {
@@ -202,7 +208,9 @@ class Runner {
202208
fs.readdirSync(dirpath)
203209
.filter((file) => path.extname(file) === '.ts')
204210
.forEach((file) => {
205-
const query = fs.readFileSync(`${dirpath}/${file}`, { encoding: 'utf-8' })
211+
const query = fs.readFileSync(`${dirpath}/${file}`, {
212+
encoding: 'utf-8',
213+
})
206214
const typeDefs = query.match(/type\s+(?!Query|Mutation)(\w+)\s*{[^}]*}/g)
207215

208216
if (typeDefs) {

0 commit comments

Comments
 (0)