DEV Community

loading...

Lessons Learned Migrating APIs to GraphQL πŸ“

swcarlosrj profile image Carlos Rufo ・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 πŸ‘‡

GraphQL Resolvers: Best Practices
*GraphQL resolvers can be easy to build, but difficult to get right. Here’s a look at PayPal’s best practices for…*medium.com

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!

Discussion (0)

pic
Editor guide