Skip to content

GraphQL INC Details #1080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions GraphQL/Sample INC Details GraphQL Code Snippet/CMDB Resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(function process(/*ResolverEnvironment*/ env) {

var user= env.getSource();
var CI = new GlideRecord("cmdb_ci");
CI.addQuery("sys_id",CI);
CI.query();
return CI;


})(env);
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
schema {
query: Query
}

type Query {
EntersysID(sys_id:ID!):incident
}

type incident{
sys_id:DisplayableString
number:DisplayableString
short_description:DisplayableString
caller_id: User @source(value:"caller_id.value")
cmdb_ci: CI @source(value:"cmdb_ci.value")
}

type User{
sys_id:DisplayableString
user_name:DisplayableString
first_name:DisplayableString
last_name:DisplayableString
email:DisplayableString
}

type CI{
sys_id:DisplayableString
install_status:DisplayableString
name:DisplayableString
}

type DisplayableString{
value:String
display_value:String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(function process(/*ResolverEnvironment*/ env) {

var sys_id=env.getArguments().sys_id;
var INC = new GlideRecord("incident");
INC.addQuery("sys_id",sys_id);
INC.query();
return INC;


})(env);
8 changes: 8 additions & 0 deletions GraphQL/Sample INC Details GraphQL Code Snippet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Example of incident query for GraphQL API
The code within this filder is just an example of working and basic implementation of sample incident details schema using GraphQL API in ServiceNow. It consist of:

1. schema (schema.gql)
2. scripted resolvers (.js extension)
3. json file representing the resolver mappings (key is Path, value is Resolver)
This is just an example
So read it, learn it and explore GraphQL 😊
10 changes: 10 additions & 0 deletions GraphQL/Sample INC Details GraphQL Code Snippet/User Resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(function process(/*ResolverEnvironment*/ env) {

var user= env.getSource();
var User = new GlideRecord("sys_user");
User.addQuery("sys_id",user);
User.query();
return User;


})(env);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"incident:cmdb_ci": "CMDB Resolver",
"incident:caller_id": "User Resolver",
"Query:EntersysID":"Incident Resolver"
}
Loading