Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GraphQL and Schema-First Development
Search
Kōhei Yamamoto
June 28, 2018
Technology
4
3.7k
GraphQL and Schema-First Development
GraphQL NightでのLT発表資料です
Kōhei Yamamoto
June 28, 2018
Tweet
Share
More Decks by Kōhei Yamamoto
See All by Kōhei Yamamoto
一休.comレストランのRustバックエンド開発の様子
kymmt90
15
10k
レガシーWebアプリケーションの性能とコードの健全性をインクリメンタルに改善する / pepabotech-20211209
kymmt90
1
2k
コードレビュー座学 / About code reviews
kymmt90
0
6.4k
ペパボのWebサービス 開発スタイル / Web services development at GMO Pepabo
kymmt90
2
530
EC新サービスにおけるスキーマファースト開発 / Schema First Development in the New EC Service
kymmt90
1
2.1k
rails new --api してからやったこと 〜2017年・夏〜 / EC Tech MTG 3
kymmt90
0
700
カテゴリ階層の拡張を目的とした階層的トピックモデル / A hierarchical topic model for expanding category hierarchies
kymmt90
0
400
Other Decks in Technology
See All in Technology
v-modelの歩みを振り返る
bengo4com
5
2.4k
Brakeman を欺く - Kashiwa.rb #4
kozy4324
1
100
寒冷地稲作の歴史にみるコミュニティ
miu_crescent
2
140
APIs for AI: Have we failed?
zdne
0
130
実は仲良し?Amplify Gen2と生成AI
mkdev10
0
150
暴カワでビデオシンセサイザーを導入する技術
yuchi
2
130
Delta Commit…の最近...
akuwano
2
130
Cosmos DB で持続可能な RAG を実現しよう!~ AOAI Dev Day ふりかえりを添えて / Sustainable RAG with Cosmos DB with recap AOAI Dev Day
miyake
0
180
まだ間に合う! 生成AIトレンド一挙おさらい & AWSのBedrockに入門しよう
minorun365
PRO
4
310
入社半年(合計1年)でGoogle Cloud 認定を全冠した秘訣🤫
risatube
1
280
From naive to advanced RAG: the complete guide
glaforge
0
680
Automated Tests Now and Future @ SQiP Workshop Special Lecture 2024
teyamagu
PRO
2
490
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
51
13k
GraphQLの誤解/rethinking-graphql
sonatard
66
9.9k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
5
130
Teambox: Starting and Learning
jrom
132
8.7k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
40
2.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
504
140k
Gamification - CAS2011
davidbonilla
80
5k
A Modern Web Designer's Workflow
chriscoyier
692
190k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
225
22k
Transcript
,ōIFJ:BNBNPUP!LZNNU (SBQI2-φΠτ-5 (SBQI2-ͱ εΩʔϚϑΝʔετ։ൃ
(.0ϖύϘΧϥʔϛʔϦϐʔτCMPHLZNNUDPN ,ōhei Yamamoto /!LZNNU SVCZSBJMTZPLPIBNBSC
None
͋ΒͨΊͯհ͠·͢
εΩʔϚϑΝʔετ։ൃ wϑϩϯτΤϯυ '& ͱόοΫΤϯυ #& ؒͷ ΠϯλʔϑΣʔεఆٛΛ։ൃνʔϜͰઌʹܾΊΔ wͦͷ͋ͱ'&#&ʹ͔Εͯฒߦ։ൃ͢Δ
ฒߦ։ൃ w'&#&ͷ࣮͕ऴΘΔ·ͰϞοΫαʔόΛͬͨΓ ͢Δ w3&45ͷ߹ w0QFO"1* 4XBHHFS ͰઌʹΠϯλϑΣʔεΛॻ͘ wपลπʔϧ 4XBHHFS$PEFHFOͳͲ Λͬͯ
ϞοΫαʔόΛ࡞Δ
ΠϯλʔϑΣʔεఆٛྫ 0QFO"1*ͷ߹ paths: /pets/{petId}: get: parameters: - name: petId in:
path required: true schema: type: string responses: '200': content: application/json: schema: required: - id - name properties: id: type: integer format: int64 name: type: string (&5QFUTQFU@JE
ΧϥʔϛʔϦϐʔτ εΩʔϚϑΝʔετ։ൃ͍ͯ͠·͢ '&7VFKT #&3BJMT
(SBQI2-ͰεΩʔϚϑΝʔετ։ൃ w3&45"1*ͰεΩʔϚΛܾΊ͔ͯΒ'&ͱ#&Ͱ ฒߦ։ൃΛਐΊΔͷศརͩͬͨ wҰ෦(SBQI2-Λಋೖͯ͠Έ͍ͯΔ w3BJMTͳͷͰHSBQIRMSVCZ w(SBQI2-Ͱಉ͡Α͏ʹͰ͖ͳ͍͔ʁ
(SBQI2-ʹ͓͚ΔεΩʔϚϑΝʔετͱ wεΩʔϚ͚ͩઌʹܾΊΔ w#&SFTPMWFSΛ͋ͱͰ࣮͢Δ w'&͕͏ϞοΫαʔόͲ͏͢Δʁ
"QPMMPͱHSBQIRMSVCZΛ Έ߹ΘͤͯϞοΫαʔόΛ࡞ΕΔ
HSBQIRMSVCZ w3VCZͷγϯλοΫεͰ(SBQI2-εΩʔϚΛॻ͘ w(SBQI2-ͷεΩʔϚΛμϯϓͰ͖Δ
3VCZͰεΩʔϚΛॻ͘ class Types::QueryType < Types::BaseObject field :viewer, Types::UserType, null: true
# resolverΛॻ͍ͯͳ͍ʂ end class Types::UserType < Types::BaseObject field :email, String, null: true field :popularPosts, [Types::PostType], null: true # resolverΛॻ͍ͯͳ͍ʂ end class Types::PostType < Types::BaseObject field :title, String, null: true end
HSBQIRMSVCZͰεΩʔϚΛμϯϓ FooBarSchema.to_definition # ҎԼͷจࣈྻΛऔಘ͢Δ type Query { viewer: User }
type User { email: String popularPosts: [Post!] } type Post { title: String }
"QPMMP w"QPMMPͷ(SBQI2-5PPMTΛ͏ w.PDLJOHͱ͍͏ػೳ͕͋Δ w(SBQI2-ͷεΩʔϚΛ৯ΘͤΔͱϞοΫαʔό͕ ࡞ΕΔ
(SBQI2-5PPMTͰϞοΫαʔό // express, graphql-express, body-parserͳͲΛrequire import { addMockFunctionsToSchema, makeExecutableSchema }
= require('graphql-tools'); const schema = makeExecutableSchema({ /* μϯϓͨ͠εΩʔϚจࣈྻ */ }); const mocks = require('./mocks') addMockFunctionsToSchema({ schema, mocks }); const app = express(); app.use('/graphql', bodyParser.json(), graphqlExpress({ schema })); app.listen(3000, () => { console.log('GraphQL mock server is running!!1'); });
(SBQI2-5PPMTͰϞοΫαʔό // mocks.js module.exports = { User: () => ({
email: '
[email protected]
', }), Post: () => ({ title: 'The Awesome Post', }), }; ϞοΫαʔό͕ฦ͢μϛʔσʔλΛॻ͚Δ ࢦఆ͠ͳ͚ΕεΧϥʔܕͷ"QPMMP͕ దʹฦ͢
ϞοΫαʔόͷ1045HSBQIRMΛୟ͍༷ͨࢠ
"QPMMPͱHSBQIRMSVCZΛ Έ߹ΘͤͯϞοΫαʔόΛ࡞Εͨ
εΩʔϚϑΝʔετ։ൃͰ͖Δʂ ศརʂʂ
ৄͪ͘͜͠ΒͰ HJUIVCDPNLZNNUTDIFNBpSTUHSBQIRMFYBNQMF
ࢀߟ wIUUQCMPHLZNNUDPNFOUSZNPDLJOHHSBQIRMTFSWFSXJUI SBJMTBOEBQPMMP wIUUQTXXXBQPMMPHSBQIRMDPNEPDTHSBQIRMUPPMT NPDLJOHIUNM