Hey In this blog, we will be learning about the introduction of Graphql.
Here is a Table of Contents.
What is GraphlQL?
When to use GraphQL?
Why use GraphlQL?
What is GraphQL
GraphQL is a query language for your API and a server-side runtime for executing queries using a type system you define for your data. GraphQL isn't tied to any specific database or storage engine and is instead backed by your existing code and data.
In simple words, GraphQL helps front-end developers by enabling them to fetch the required data they want in the application.
for eg.
if this is the type of user in our database.
`type Query {
me: User
}
type User {
id: ID
name: String
}`
but as a frontend developer we only need a name, and don't need the id property we can only fetch the name property using GraphQL.
this query.
{
me {
name
}
}
will generate this JSON output.
{
"me": {
"name": "Luke Skywalker"
}
}
When to use GraphQL?
The best scenario to use GraphQL is when you want to provide a better experience to your developers. With the descriptive language to handle complex queries, the capability to simplify the loading of state management, and the facility to manipulate types instead of tweaking with JSON data.
Why use GraphlQL?
GraphQL allows making multiple resource requests in a single query call, which saves a lot of time and bandwidth by reducing the number of network round trips to the server. It also helps to save waterfall network requests, where you need to resolve dependent resources on previous requests.
We talked about basics introduction of graphql and in next blog will come with another topic.
Stay Tuned.
Top comments (0)