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.5k
レガシーWebアプリケーションの性能とコードの健全性をインクリメンタルに改善する / pepabotech-20211209
kymmt90
1
1.4k
コードレビュー座学 / 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
380
Other Decks in Technology
See All in Technology
「認証認可」という体験をデザインする ~Nekko Cloud認証認可基盤計画
logica0419
2
360
事前準備が肝!AI活用のための業務改革
layerx
PRO
1
340
Estrategias de escalabilidade para projetos web
jessilyneh
2
230
Privacy Sandbox on Android / DroidKaigi 2024
7pairs
1
170
OCI で始める!! Red Hat OpenShift / Get Started OpenShift on OCI
oracle4engineer
PRO
1
150
突撃! 隣のAmazon Bedrockユーザー 〜YouはどうしてAWSで?〜
minorun365
PRO
3
350
ナレッジグラフとLLMの相互利用
koujikozaki
0
360
20240911_New_Relicダッシュボード活用例
speakerdeckfk
0
100
LINEヤフーのフロントエンド組織・体制の紹介
lycorp_recruit_jp
0
830
Oracle Database Backup Service:サービス概要のご紹介
oracle4engineer
PRO
0
4.1k
LLVM/ASMを使った有限体の高速実装
herumi
0
120
四国クラウドお遍路 2024 in 高知 オープニング
yukataoka
0
190
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1029
450k
Writing Fast Ruby
sferik
623
60k
Designing with Data
zakiwarfel
98
5k
The Invisible Customer
myddelton
119
13k
Code Reviewing Like a Champion
maltzj
518
39k
What's new in Ruby 2.0
geeforr
340
31k
Rails Girls Zürich Keynote
gr2m
93
13k
YesSQL, Process and Tooling at Scale
rocio
167
14k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
225
22k
The Cost Of JavaScript in 2023
addyosmani
42
5.5k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
25
3.9k
Robots, Beer and Maslow
schacon
PRO
157
8.1k
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