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
Typescriptで始めるGraphQL入門_LG勉強会.pdf
Search
ruribou
July 10, 2025
Technology
35
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Typescriptで始めるGraphQL入門_LG勉強会.pdf
ruribou
July 10, 2025
More Decks by ruribou
See All by ruribou
好きなゲーム発表LT
ruribou
0
10
登竜門Hack2026_AI勉強会_講義資料
ruribou
0
39
!コスパよくインターンに受かる方法!
ruribou
1
370
『From Techer To Future』を体現するという宣誓
ruribou
0
54
僕がイベント運営をする理由
ruribou
0
96
優秀じゃないのはみんな同じだって、そろそろ気づきませんか?
ruribou
1
210
Lovendar
ruribou
1
50
Other Decks in Technology
See All in Technology
「どのログを見ればいい?」 から始めた サーバーレス障害解析
y_waka1
1
130
データ_AIの事業の勝敗をわけるもの
nek0128
1
480
ほんとうの信頼性はヒーローが死んでからはじまる / True reliability begins after the hero dies
vtryo
0
110
Why Agent Cost Needs Observability
nttcom
0
140
おい、エージェントを使って終わらせろ
nwiizo
3
870
C#コードの結合を可視化する Roslyn解析による設計改善と リファクタリング判断
dora56
0
450
負債のメタファと2026年 / Debt Metaphor in Agentic Engineering Age 202609 Edition
twada
PRO
11
6.2k
AIによるクリエイティブ生成を行う上での試行錯誤
plaidtech
PRO
0
180
AgentCore Runtime上にAgentic Coding基盤を構築・展開する際の設計ポイントと限界点 / Design considerations and limitations when building an agentic coding platform on AgentCore Runtime
har1101
5
690
Claude in Chrome 入門 / Introduction to Claude in Chrome
cielo1985
0
890
AIを活用するために決めた "やらないこと" - 価値に注目する / Not betting on AI
soudai
PRO
3
590
CLIライブラリ開発を支える技術
htnabe
0
150
Featured
See All Featured
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Designing for Performance
lara
611
70k
Building Adaptive Systems
keathley
44
3.2k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
The Cost Of JavaScript in 2023
addyosmani
55
10k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
530
Ethics towards AI in product and experience design
skipperchong
2
380
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Raft: Consensus for Rubyists
vanstee
142
7.7k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
550
Transcript
Typescript Ͱ࢝ΊΔ GraphQL ೖ גࣜձࣾϥϒάϥϑ ։ൃΠϯλʔϯ ઙҪྋଠ 2025/06/25 created by
ruribou
ࣗݾհ ઙҪ ྋଠʢ͍͋͞ Γΐ͏ͨʣ ౦ژిػେֶཧֶ෦ཧֶՊ ಛఆඇӦར׆ಈ๏ਓ NxTEND झຯ↓ ཱྀɺٿ؍ઓɺΞΠυϧϚελʔ
ࠓճ͢͜ͱ • GraphQLͱͳʹ͔ • ۩ମతͳ࣮ • ࣮ࡍʹୟ͍ͯΈΔ͜ͱ
ࠓճ͞ͳ͍͜ͱ • GraphQLͷ࣮༻ੑ • Ԡ༻ྫ
GraphQL ͱͳΜͧ
HTTPܦ༝ͰDBαʔϏεΛૢ࡞͢Δ ͨΊͷSQLతͳݴޠʴΈ
۩ମతͳҧ͍ • ΫϥΠΞϯτओಋͰඞཁͳใ͚ͩΛऔಘ • RailsͷREST APIͩͱɺ/users/1 → ݻఆͷJSON͕ؼͬͯ͘Δͷʹରͯ͠GraphQLΫϥΠ Ξϯτ͕{ user(id:1)
{ id, name, posts { title } } } ͷΑ͏ʹɺʮͲͷϑΟʔϧυ͕΄͍͔͠ʯ Λࣗ༝ʹهड़Ͱ͖Δ • ୯ҰΤϯυϙΠϯτ & ౷Ұతͳૢ࡞Ϟσϧ • Rails ͷίϯτϩʔϥ×HTTPϝιουʢGET/POST/PUT/DELETEʣͰଟͷΤϯυϙΠϯ τΛཧ͢ΔΘΓʹɺGraphQL جຊతʹ /graphql 1͚ͭͩ
࣮ฤ
ࠓճͷٕज़ߏ Typescript + Hono + Prisma + Supabase + GraphQL
Hono • ຊਓ͕࡞ͬͨɻTypescriptͷܰྔͰߴੑೳͳWebϑϨʔϜϫʔΫɻ • όοΫΤϯυΊͪΌΫιָɻ
Prisma • ݴΘͣͱΕͨJavascipt / Typescript ͷORM • σʔλϕʔεϚΠάϨʔγϣϯͰ͖ΔΑ
Supabase PostgreSQL ΛϕʔεʹೝূɾετϨʔδɾϦΞϧλΠϜػೳΛඋ͑ͨ ΦʔϓϯιʔεͷόοΫΤϯυଈ੮αʔϏε
ࠓճ߃ྫ͚ͩͲTodoΞϓϦͰ ࣮͍ͯ͘͠Α
PrismaͷεΩʔϚ model Todo { id Int @id @default(autoincrement()) title String
completed Boolean @default(false) createdAt DateTime @default(now()) }
GraphQL εΩʔϚఆٛ export const schema = ` type Todo {
id: Int! title: String! completed: Boolean! createdAt: String! } type Query { todos: [Todo!]! } type Mutation { addTodo(title: String!): Todo! toggleTodo(id: Int!): Todo! deleteTodo(id: Int!): Boolean! } `; ɾʮʂʯඞਢΧϥϜ ɾܕఆٛͱ۩ମతͳૢ࡞Λ QueryͱMutationͰఆٛ
QueryͱMutationͱ • Query • CRUDͷRʢREADʣΛ୲ • RESTͰ͍͏ͱGET • Mutation •
CRUDͷCʢCreateʣ, UʢUpdateʣ, DʢDELETEʣΛ୲ • RESTͰ͍͏ͱPOST/PUT/PATCH/DELETE͋ͨΓ • Subscription • αʔόʔͷߋ৽ΛϦΞϧλΠϜͰ௨ʢྫɿଞਓͷૢ࡞Λଈ࣌มߋʣ • ࠓճΘͳ͍
Resolver ͷ࣮
ResolverͬͯͳΜͧ • SchemaͰԿ͕Ͱ͖Δ͔Λఆٛ͠ɺ͜ͷResolverͰͦΕΛͲ͏࣮ݱ͢Δ͔Λ࣮͢Δ • ۩ମతͳCRUDૢ࡞ͷதͱݴ͑Δ • SchemaͰఆٛ͞ΕͨQueryMutation͕࣮ࡍʹͲͷΑ͏ʹͯ͠σʔλΛऔಘɺมߋ͢Δ ͷ͔Λ۩ମతʹ࣮
۩ମతͳ࣮ const rootResolver: RootResolver = () => ({ todos: async
() => { const todos = await prisma.todo.findMany({ orderBy: { createdAt: 'desc' } }); return todos.map(todo => ({ ...todo, createdAt: formatDate(todo.createdAt), })); }, addTodo: async ({ title }: { title: string }) => { const todo = await prisma.todo.create({ data: { title } }); return { ...todo, createdAt: formatDate(todo.createdAt), }; }, toggleTodo: async ({ id }: { id: number }) => { const todo = await prisma.todo.findUnique({ where: { id } }); if (!todo) throw new Error('Not found'); const updated = await prisma.todo.update({ where: { id }, data: { completed: !todo.completed }, }); return { ...updated, createdAt: formatDate(updated.createdAt), }; }, deleteTodo: async ({ id }: { id: number }) => { const todo = await prisma.todo.findUnique({ where: { id } }); if (!todo) return false; await prisma.todo.delete({ where: { id } }); return true; }, });
ΫΤϦૢ࡞Λͯ͠ΈΔ
͕ࣗೖͨ͠ײ • ΫϥΠΞϯτ͕ຊʹඞཁͳใͷΈΛ͚ͨͨΔͷ͕ྑ͍ • REST APIͩͱʮޙ͔Β͜ͷใ͕ཉ͍͠ʯʮ͜ͷใ༨ܭͩʯΈ͍ͨͳ͜ͱ͕ ݁ߏى͖͏Δ • ܕ͖εΩʔϚͳͷͰɺͲΜͳΫΤϦ͕͛ΒΕΔͷ͔Ϩεϙϯεʹ͍ͭͯɺܕͱͯ͠ ѲͰ͖Δ҆৺ײ͕͋Δ
• Honoͱ૬ੑ͕ྑ͔ͬͨͷͰخ͍͠