The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
VaranAwesomenow
Kilo Sage
Kilo Sage
This article talks about how to create a simple graphql api to read incident data,
it has a video demo and link to updateset.
Below are various components involved in the setup
GraphQL API, Script include,Fix script to test script include,GraphQL Scripted Resolver
GraphQL Resolver Mappings
Tool used : Insomnia
Updateset share link :

Sample rest client curl code
curl --request POST \
  --header 'Authorization: Basic YWRtaWxxxx5hbmlsOk15QWRtaW5QQDU1dzByZA==' \
  --header 'Content-Type: application/json' \
  --cookie 'JSESSIONID=44109CA8241B7CD5F603C263E0D51154;
glide_user_route=glide.76e8af3a511b2a4fdde7579126346f2b;
BIGipServerpool_dev111463=2710591498.39230.0000;
glide_user_activity=U0N2M18xOjlrZ2hVYS9rYW0xakdXTnhzem9nTkZYO
WNaVllwQVRiTEtJT0pLcExpTDg9Ok40czA4VnlJM2ZtVzRKNXo1WGk1cW5zUGxSdDhPWDd2eVkzY0poa1JmU3M9' \
  --data '{"query":"query {\n\tx146833 {\n\t\tvaranGqlInc {\n\t\t\tgetIncident
(id: \"f12ca184735123002728660c4cf6a7ef\")
{\n\t\t\t\tactive\n\t\t\t\tstate\n\t\t\t\tid\n\t\t\t\tpriority\n\t\t\t
\tseverity\n\t\t\t\tdescription\n\t\t\t}\n\t\t}\n\t}\n}\n","operationName":"Operations"}'
 
Below is a summary of various components demoed in the video.
1. GraphQL API -> This is the API definition that has schema, graphql scripted resolver and
graphql resolver mappings.
2. Script include -> This contains the functions needed to perform CRUD operations in
ServiceNow and provide relevant output to GraphQL API
3. Fix script -> Is used to test the script include to ensure that it has relevant
configuration needed to provide response to API calls.
4. graphql scripted resolver -> Is a script-able configuration that calls script include
from graphql api
5. graphql resolver mapping -> This maps query defined in graphql schema with graphql
scripted resolver.
 
 
 
 
 
 
 
 
3 Comments