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
14
9.3k
レガシーWebアプリケーションの性能とコードの健全性をインクリメンタルに改善する / pepabotech-20211209
kymmt90
1
1.2k
コードレビュー座学 / About code reviews
kymmt90
0
6.4k
ペパボのWebサービス 開発スタイル / Web services development at GMO Pepabo
kymmt90
2
520
EC新サービスにおけるスキーマファースト開発 / Schema First Development in the New EC Service
kymmt90
1
2k
rails new --api してからやったこと 〜2017年・夏〜 / EC Tech MTG 3
kymmt90
0
680
カテゴリ階層の拡張を目的とした階層的トピックモデル / A hierarchical topic model for expanding category hierarchies
kymmt90
0
370
Other Decks in Technology
See All in Technology
20分で分かるIAM全機能 (拡大版) / 20240903-jawsug-yokohama-iam
opelab
3
120
脆弱星に導かれて
nishimunea
1
1.5k
バックログを導入し やっぱやめた話
ota42y
0
170
自社開発した大規模言語モデルをどうプロダクションに乗せて運用していくか〜インフラ編〜
pfn
PRO
4
680
Datadog を使ったプロダクトとクラウドの セキュリティモニタリング
mrtc0
0
450
セキュリティ監視の内製化 効率とリスク
mixi_engineers
PRO
4
640
#Zenoh 完全に理解した 〜組込み純情篇〜
takasehideki
1
450
X-Correlation Injections (or How to break server-side contexts)
fransrosen
0
360
20240906_JAWS_Yamanashi_#1_leap_beyond_the_AWS_all_certifications
tsumita
1
100
React Aria で実現する次世代のアクセシビリティ
ryo_manba
3
290
歴史と背景から改めて振り返るVPC
shotashiratori
2
220
手軽に始める? おうちサーバーのすゝめ
nyagasan
0
180
Featured
See All Featured
Statistics for Hackers
jakevdp
793
220k
Faster Mobile Websites
deanohume
304
30k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.4k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Navigating Team Friction
lara
183
13k
In The Pink: A Labor of Love
frogandcode
139
22k
It's Worth the Effort
3n
182
27k
Ruby is Unlike a Banana
tanoku
96
10k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
25
1.3k
The Pragmatic Product Professional
lauravandoore
30
6.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
263
13k
Atom: Resistance is Futile
akmur
261
25k
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