Lessons Learned Migrating APIs to GraphQL πŸ“

Carlos Rufo
Dec 5, 2018 Β· 2 min read

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 πŸš€

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

Open GraphQL

Anything & Everything GraphQL

Carlos Rufo

Written by

πŸ¦„ Engineering @GraphCMS 🌈 Organizer @GraphQLMadrid 🌠 Author of http://api.spacex.land 🌍 Es 🌎 En 🌏 δΈ­ ✊🏿 #BlackLivesMatter

Open GraphQL

Anything & Everything GraphQL