RapidAPI Profile picture
Mar 4 β€’ 14 tweets β€’ 2 min read
Let's discuss five best practices for designing GraphQL APIs.

A Thread 🧡 πŸ‘‡πŸ»
GraphQL solves the problem of over-fetching and under-fetching that we often get in REST API.
If you are unaware of these two terms.

Over-fetching is fetching too much data.

Under-fetching is not having enough data, forcing you to call a second endpoint.
The GraphQL API is designed to provide you with the precise amount of data you request.
Following best practices can make your GraphQL API stand out.

Here are a few points on best practices you should consider while building a GraphQL API. πŸ‘‡πŸ»
1️⃣ Name All GraphQL Operations

There are two ways to create GraphQL queries:

- You can do it anonymously, or
- You can provide it with a name.

The second way is the best way to do it.
You should always provide a name to GraphQL operations in your application.

This will help users to understand the purpose of a query.

It also helps with the debugging operation.
2️⃣ Only Query The Data You Need

The most significant advantage of GraphQL over REST API is its ability to fetch only the data the client needs.

So when you are designing a GraphQL API, make sure that you request exactly the data you need.
3️⃣ Use Fragments

You should use fragments to encapsulate related fields.

The fragment can be shared across multiple operations, and this will make your queries short, consistent, and more readable than before.
A fragment is nothing but a piece of logic that can be shared between multiple queries and mutations.
4️⃣ Query Global And User Data Separately

When developing an application, some global data is common across all users. But there is also some user-specific data.

It is a good practice that you query both types of data separately.
This way, it can also be cached separately.

So if a different user is now using a computer that was used by another user earlier, your app would only need to fetch the new user data and use the global data from the cache.
5️⃣ Avoid Versioning

No need to create breaking changes as GraphQL returns explicitly requested data.

New data can be added using new fields and types. Hence no need to implement versioning.

Versionless is the most underrated benefit of GraphQL.
With that being said, this is the end of this thread.

Follow @Rapid_API for more exciting content like this one. πŸ™ πŸ’™

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with RapidAPI

RapidAPI Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Rapid_API

Mar 3
A brief introduction to ten widely used HTTP Headers.

A Thread πŸ§΅πŸ‘‡πŸ»
In this thread, we are going to discuss:

β€’ Accept
β€’ Accept-Encoding
β€’ Authorization
β€’ Accept-Language
β€’ Content-Type
β€’ Content-Location
β€’ Content-Encoding
β€’ Content-Length
β€’ Content-Language
β€’ Cache-Control
Client and server can pass the extra bit of information with the request and response using HTTP headers.

HTTP headers are not case-sensitive.
Read 15 tweets
Mar 3
Top ten Food APIs you can use in your next project.

A Thread πŸ§΅πŸ‘‡πŸ»
1️⃣ Recipe-Food-Nutrition

Over 365,000 recipes and 86,000 food products. Analyze food images by uploading a file or by a given URL.

πŸ”— RapidAPI.com/spoonacular/ap…
2️⃣ Tasty

Use the Tasty API to get data about recipes, ingredients, nutrition, and much more. You can also filter recipes according to the time they take.

πŸ”— RapidAPI.com/apidojo/api/ta…
Read 12 tweets
Mar 2
Building an API is not difficult as it sounds.

Let's create a quick number API using which we can fetch even, odd, and prime numbers.

Thread πŸ§΅πŸ‘‡πŸ»
Prerequisite:

We are assuming you have Node.js installed on your machine. If you haven't installed it, click on the following link and install it simply.

nodejs.org/en/
Let's start with creating an empty directory and initializing the project by running the following command. Creating an empty directory...
Read 21 tweets
Mar 2
Top ten Facial Recognition APIs.

Thread πŸ§΅πŸ‘‡πŸ»
1️⃣ Mirror-AI

Upload photos and get personalized avatars and emojis for your users.

πŸ”— RapidAPI.com/mirror-dev-tea…
2️⃣ Face Detection

Use Face Detection API to detect the location of human faces in your images with optional extra features like Age and Gender.

πŸ”— RapidAPI.com/inferdo/api/fa…
Read 12 tweets
Mar 1
Everything you need to know about SOAP API.

Thread πŸ§΅πŸ‘‡πŸ»
SOAP is a necessary protocol that helped introduce the widespread use of APIs.

SOAP is the acronym for Simple Object Access Protocol.
SOAP is a standardized protocol that relies on XML to make requests and receive responses.

Even though SOAP is based on XML, the SOAP protocol is still in wide usage.
Read 18 tweets
Mar 1
Anatomy of an API endpoint.

Thread πŸ§΅πŸ‘‡πŸ»
Before breaking the endpoints into multiple parts. Let's first see what exactly is an endpoint.

The endpoint is nothing but the URL to access resources.

Every API must have at least one endpoint.
A typical endpoint or URL starts with the scheme.

Scheme is nothing but the protocol for APIs.

For example, HTTPS, HTTP, FTP, SSL, etc. Anatomy of an endpoint showing scheme.
Read 10 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(