Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
NestJS GraphQL開発を支える 自作CodeGenerator
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
fujitani sora
December 18, 2024
74
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
NestJS GraphQL開発を支える 自作CodeGenerator
fujitani sora
December 18, 2024
More Decks by fujitani sora
See All by fujitani sora
TypeScript * xx 一年目の振り返り
fujitanisroa0414
0
250
Terminal IDE の世界
fujitanisroa0414
1
320
RubyでNeoVim Pluginを作る技術
fujitanisroa0414
0
130
toridori DevRel 立ち上げ約半年の成果と今年の目標
fujitanisroa0414
0
340
なぜtoridori開発部はDevRelに取り組むのか
fujitanisroa0414
1
140
AWS SDK for PHPによる AmazonECS構成管理
fujitanisroa0414
2
550
ARR成長の為に開発者個人で出来る事
fujitanisroa0414
0
280
育成ゲームとしてのvim(桃太郎)
fujitanisroa0414
0
84
書籍紹介 「採算に乗る事業」の仕組みづくり
fujitanisroa0414
0
110
Featured
See All Featured
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
850
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
Being A Developer After 40
akosma
91
590k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
480
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
Bash Introduction
62gerente
615
220k
Mobile First: as difficult as doing things right
swwweet
225
10k
A Tale of Four Properties
chriscoyier
163
24k
So, you think you're a good person
axbom
PRO
2
2.2k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
58k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
900
Transcript
NestJS GraphQL開発を支える 自作CodeGenerator mita.ts 5分LT fujitani sora
名前 ・藤谷 想楽(ふじたに そら) ・@_fs0414 ・2001(23) 所属 ・株式会社トリドリ ・開発統括部 ・エンジニア,
DevRel 自己紹介 TsKaigi2025の運営メンバーやったりもしてます。 イベントページ公開されてます! https://2025.tskaigi.org/
2022 12月19日 東証グロース市場 に 上場 2016 2017 2019 10月 インフルエンサー広告
プラットフォームシステム アップロント を展開 株式会社 アップロント 設立 2020 8月 インフルエンサー マネジメント事務所 OTOZURE 設立 株式会社 コラボテクノ ロジー に社名変更 インフルエンサー広告 プラットフォームシステム コラボマーケ ティング & コラボベース をリリース 渋谷 オフィス に移転 株式会社 トリドリ に社名変更 各サービス toridori シリーズ へ名称変更 2021 7月 株式会社 GIVIN と事業統合 インフルエンサーブランド 立ち上げ支援 toridori made 始動 10月 10月 9月 6月 沿革 2023 12月 株式会社 OverFlow と事業統合
6つの事業を通して インフルエンサーマーケティング を展開しています ※グループ会社
@toridori_tech(X) @toridori tech blog(Zenn) 会社のNote(Note)
shibuya.tsやります 2/5 WeWork 渋谷スクランブルスクエア 41F 登壇枠は一旦埋まりましたが増枠予定なのでwatchしておいてもらえますと! https://arc.net/l/quote/pzpnyxis
toridoriのNestJS GraphQL • Dmian単位でFeatureModuleに分割し、必要なファイルを配置している • Resolver • Model • Service
• Entity • QueryService • Repository • DTO • TxService(Transaction管理用Class) • etc… FeatureModule 特定のドメインに関連する Contoller, Service, Repositoryなどをまとめた Module。
新しいFeatureModuleを作成したい • Resolver 1. ファイルを作成していつものコードを記述 2. index.tsでexport • Module 1.
ファイルを作成してinports, providers, exportsを記述 2. graphql.module.tsにFeatureModuleを登録 • 手で毎回作成しているとミスも起きる • デフォルトのNest CLIだけだと、プロジェクト独自のClass生成に対応できない • 新しいFeatureModuleを作成する時は、大体ServiceとかRepositoryとかも一度に必要。 ◦ [ExceptionHandler] Nest can't resolve dependencies 🥺 ◦ 個別に作って依存解決を気にするのはめんどくさい
これらの課題を解決する為に、 nest-commander, ts-morph, enquirerを活用した自作CodeGeneratorを運用している
package.jsonのscriptsに登録して簡単に実行できる コードはcliディレクトリに配置
code-genコマンド step1 • 生成したいComponentを選択する • 複数選択可能 • ロジック内のの抽象化されたコードは載せていません。そのうちZennに書きたい
code-genコマンド step2 • ファイル名を入力する ◦ ファイル名 + Compoment名になる • resolver,
modelなど他のCompomentでも 同様の依存解決を行なっている
code-genコマンド step3 • 作成するドメイン = NestJs FeatureModuleを指定 • 指定したリソースが自動で生成されている。うれしい
code-genコマンド 生成したコード • 頻出のボイラープレートコードを自動で生成してくれる ◦ GraphQLのNodeInterface ◦ 認証に使うGuardの実装 ◦ ModuleでのDI解決
◦ etc… • 便利