Lessons Learned Migrating APIs to GraphQL ๐Ÿ“

Carlos Rufo
Dec 5, 2018 ยท 2 min read
Image for post
Image for post

This post shows best practices ๐Ÿ’ซ of migrating APIs to GraphQL. Add your thoughts, collabore asking/resolving concerns ๐Ÿค—, show them your folks, but ๐Ÿ™๐Ÿป, share knowledge ๐Ÿ’œ

Lessons Learned

Modularize ๐Ÿ‘Œ your typeDefs & resolvers ๐Ÿ‘‡

โ€œBreak your schema by concern, not by typesโ€œโ€Šโ€”โ€ŠMartijn Walraven ๐Ÿ‘‡

DRY โ™ป๏ธ, use context! ๐Ÿ‘‡

Evaluate whether your schema is feature or domain based ๐Ÿ‘‡

Show whatโ€™s important ๐Ÿ‘€ first ๐Ÿ‘‡

Decouple global typeDefs! ๐Ÿ‘‡

Take advantage ๐Ÿš€ of ESNext ๐Ÿ‘‡

Return several types using Union Types!๐Ÿ‘‡

Use Aliases ๐Ÿ”ฅ to rename the result of a field ๐Ÿ‘‡

Donโ€™t over-engineer, you can query with fetch๐Ÿ‘‡

DRY โ™ป๏ธ, use fragments!

Get rid off your variables using Input Types ๐Ÿ‘‡

Extra ๐ŸŒŸ

Donโ€™t miss the 1st part of a series resuming PayPalโ€™s best practices for building GraphQL APIs ๐Ÿ‘‡

Recapping

๐Ÿ‘‰ Modularize ๐Ÿ‘Œ your typeDefs & resolvers
๐Ÿ‘‰ โ€œBreak your schema by concern, not by typesโ€œ โ€” Martijn Walraven
๐Ÿ‘‰ DRY โ™ป๏ธ, use context!
๐Ÿ‘‰ Evaluate whether your schema is feature or domain based
๐Ÿ‘‰ Show whatโ€™s important ๐Ÿ‘€ first
๐Ÿ‘‰ Decouple global typeDefs!
๐Ÿ‘‰ Take advantage ๐Ÿš€ of ESNext
๐Ÿ‘‰
Return several types using Union Types!
๐Ÿ‘‰ Use Aliases ๐Ÿ”ฅ to rename the result of a field
๐Ÿ‘‰ Donโ€™t over-engineer, you can query with fetch
๐Ÿ‘‰ DRY โ™ป๏ธ, use fragments!
๐Ÿ‘‰ Get rid off your variables using Input Types
โ€ฆ
โญ๏ธ
GraphQL Resolvers: Best Practices

Already waiting to add yours ๐Ÿค—, contribute adding more lessons learned ๐Ÿ‘‡

Or even betterโ€ฆ

Create posts ๐Ÿ˜€, courses ๐Ÿ˜„, meetups ๐Ÿ˜, anything!, just be ๐Ÿค— and curious for teaching & learning ๐Ÿš€

Image for post
Image for post

Iโ€™ll be following this post up ๐Ÿ”œ with more lessons learned, stay tuned!

Please, consider๐Ÿ™๐Ÿปing, contributโ™ป๏ธing and shar๐Ÿ’œing it!

Open GraphQL

Anything & Everything GraphQL

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and weโ€™ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium โ€” and support writers while youโ€™re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store