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
1.8k
コードレビュー座学 / 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
390
Other Decks in Technology
See All in Technology
とある事業会社にとっての Kaggler の魅力
hakubishin3
5
1k
WSUSが非推奨に!? Windowsの更新管理を改めて勉強する!
ebibibi
0
290
DenoでもViteしたい!インポートパスのエイリアスを指定してラクラクアプリ開発
bengo4com
2
2k
Oracle Database 23ai 新機能#4 Real Application Clusters
oracle4engineer
PRO
0
160
ドキュメントとの付き合い方を考える
leveragestech
1
150
テストを楽に書きたい
tomorrowkey
1
200
Semantic Kernel の Agent 機能試してみた!
okazuki
1
160
普通の Web エンジニアのための様相論理入門 #yapcjapan / YAPC Hakodate 2024
ytaka23
7
1.6k
LeSSはスクラムではない!?LeSSにおけるスクラムマスターの振る舞い方とは / Scrum Master Behavior in LeSS
toma_sm
0
210
JAWS PANKRATION 2024 配信システムの紹介
yoshimi0227
0
100
テクニカルライターのチームで「目標」をどう決めたか / MVV for a Team of Technical Writers
lycorptech_jp
PRO
3
120
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
2
240
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
355
29k
Happy Clients
brianwarren
97
6.7k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.6k
Mobile First: as difficult as doing things right
swwweet
222
8.8k
Faster Mobile Websites
deanohume
304
30k
How GitHub (no longer) Works
holman
311
140k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
Done Done
chrislema
181
16k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.5k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
3
230
Git: the NoSQL Database
bkeepers
PRO
425
64k
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