DEV Community

Carlos Rufo
Carlos Rufo

Posted on

Migrating SpaceX API to GraphQL 🚀

As another lover of physics, astronomy and rockets, when I found the SpaceX Public API (thanks to Full Stack Apollo tutorial 👏), I was really intrigued for looking into the available data.

I immediately accessed to the SpaceX API GitHub and …

  • 🐵s would be the future Animoji’s Hand Tracking UX tests

REST? External docs? Postman?? 😅 The SpaceX API journey didn’t start well but I was still excited for digging into the resources that make up the API, I continued my way to the Docs 😬

As always I’ve skipped the introduction and went straight to the resources in search of the holy grail, the data and their respective type definitions, let’s review what there is inside of it 👇

Endpoint, 😒 v3?, is there a v2? where’re the docs? 😕

Types, I dunno what QueryStrings is but we have some type definitions 😍

🔲 Data, no data, no 😭. Let’s keep looking, the data model should be around!

As a accustomed GraphQL user, the experience wasn’t being great but it deserved a chance 🤞

Eureka, I’ve found it 🎉

✋ a sec, original_launch_unix doesn’t look like familiar, let’s check the “type definitions” again,
🤔 it’s not there and the description always says “Filter…”
😓 that wasn’t the data type definitions,
😫 where could they be then?

*scrolling trying to find the type definitions… *

**My brain:
**Don’t say it
Don’t say it
Don’t say it
Don’t say it
Don’t say it
Don’t say it
Don’t say it
Don’t say it
Don’t say it

*Me: *“Keep calm, let’s see if we can find them over the API collection provided”

running Postman collection

installing, signing up, setting up…

**My brain:
**Don’t say it
Don’t say it
Don’t say it
Don’t say it
Don’t say it
Don’t say it
Don’t say it
Don’t say it
Don’t say it

*Me: *“What are you waiting to use GraphQL?”

Yep, I gave up 😓, right after that I started the API migration…



I just want to explore data & their types

without the need of setting anything up, and because of…

👉 Overfetching: 90% of the responses exceeds the app’s data need, I just wanna ask for what I want!

👉 Underfetching: Multiple requests are a bad performance solution, I’d love to request all the data in one

👉 Typing, documentation, versioning, *ecosystem, *…♾, are always tricky



It’s not a framework, neither a library, is a **Query Language **for APIs and as specification itself, it’s compatible with any programming language 💫

GraphQL: A query language for APIs

Master it 👩‍🎓👨‍🎓 with “Learning GraphQL” by Eve Porcello & Alex Banks

🌒🌔 The Migration 🌖🌘

What could I say about the GraphQL techs & tooling? Simply that I had deployed an API being able to interactively, fetch real data & explore full-updated docs (and much more), **within a couple hours*, just fast & fun!


1️⃣ Setup server & modular schema ⚙️
2️⃣ Include DB & builders into the context
3️⃣ Create domain’s typeDefs & resolvers 💪
4️⃣ Implement trivial resolvers
5️⃣ Apply lessons learned 💡
6️⃣ Deploy 🚀 it

Doesn’t look like difficult right?, actually it’s not thanks to the brilliant GraphQL Community 🙌, don’t miss the changes made!


Draw them yourself… (fork it, break it, improve it but especially, enjoy it 😄)

👉 The Repo & The API & The Docs & The Everything👇

Don’t miss the GraphQL best practices & conclusions based on SpaceX GraphQL API

👉 Lessons Learned Migrating APIs to GraphQL 📝 👈

Please, consider🙏🏻ing, contribut♻️ing and shar💜ing it!

Top comments (0)