DEV Community

Carlos Rufo
Carlos Rufo

Posted on

3 1

Lessons Learned Migrating APIs to GraphQL πŸ“

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!

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay