Ashutosh Munot1
Kilo Patron
Kilo Patron

What is GraphQL?

GraphQL is a query language API used to load data from Server to client which gives client exactly the data which they request and nothing more than that in JSON format.

Benefits of GraphQL:

  • Makes easy to aggregate data from different different sources
  • One API to get data from multiple tables in ServiceNow.
  • Fast, Flexible and developer friendly.
  • GraphQL does not dictate a specific application architecture. It can be introduced on top of an existing REST API and can work with existing API management tools.
  • Schema can be made public.
  • very efficient and scale-able.

GraphQL Vs REST?

  • GraphQL is a query language and REST is an architectural pattern.
  • REST returns whole data object for the component but GraphQL returns what you asked for.
  • In REST, the shape and size of the resource is determined by the server. In GraphQL, the server declares what resources are available, and the client asks for what it needs at the time.
  • Developers can summarize multiple API calls in one. Doing so allows them to focus on the business logic instead of combining call results, handling different transactions.

Will REST Fade Away?

Personally i believe NO it will not because it has its own advantages over GraphQL. REST is in market for a while now and its not easy to replace REST with GraphQL, one reason been lack of tools support for GraphQL. 

See this link which gives you lot of information about this https://goodapi.co/blog/rest-vs-graphql

Now lets come to an actual demo and how this will be helpful in ServiceNow for us as a Developer and will this solve real time issues for us or not. So lets deep dive into this concept and see what GraphQL brings to Us. I will explain GraphQL components by taking a simple example in following sections.

Use Case

Retrieve Incident details along with child incidents.

Solution:

I don't want to bore you by creating a huge article so i have explained GraphQL, its components and Use case above in this video. Watch this and get started with GraphQL.

 

References:

@Marcus Reinhardt Created a good documentation for GraphQL APIs. I have taken a reference of this document and modified few things as per my need. Indeed cred goes to thim 

https://github.com/noxify/ServiceNow-GraphQL-Example

Please don’t forget to mark helpful ,bookmark this article and subscribe my Youtube channel.

Thanks and Regards,
Ashutosh Munot

ServiceNow MVP 2019/2020

My Article and Blogs

Youtube Channel

Comments
Marcus Reinhard
Giga Contributor

Dear @Ashutosh Munot ,

 

thanks for creating the video howto.

It would be nice if you would mention me as original author of the used source.

For everyone else:

If you need the source, feel free to visit my repo: 

https://github.com/noxify/ServiceNow-GraphQL-Example

Ashutosh Munot1
Kilo Patron
Kilo Patron
Hi Marcus, Sure my apologies for this. I would do that and edit this article. I indeed took a reference and modified few things from you repo. Thanks, Ashutosh
nathanfirth
Tera Guru

Great post!

I've also created a quick tutorial for using GraphQL to query the existing ServiceNow tables available here: https://community.servicenow.com/community?id=community_blog&sys_id=d1ad30c91b94e010d2ccea89bd4bcbb9

Ashutosh Munot1
Kilo Patron
Kilo Patron

Nice Nathan. Awesome Blog.

 

Thanks,

Ashutosh

BK9
Tera Contributor

Hi,

Thank you for your hard work. 

I followed all of the steps from the script includes to the GraphQLAPIs module, but I'm getting a null return in Insomnia. What could I be missing?

 

find_real_file.png

 

 

Version history
Last update:
‎08-29-2020 05:06 AM
Updated by: