read data with graphQL using servicenow

Alexandre_dupre
Tera Contributor

Hello,

I developped a GraphQL API. I'm new on serviceNow, i got 2 questions.
My first question is : how to pass by API, not using tables to read data from the CMDB ?
My second one is about steps to developped a GraphQL API on ServiceNow, is it the right way to do this ?

I created a GraphQL schema, then i created the resolver script with the process function, then i created the Mapping resolver. But i'm still have null as an answer.

{
    "data": {
        "equse": {
            "incidentData": null
        }
    }
}



Here is the code :

 

 

 

schema {
    query: Query
}
type Query {
   getIncidentByCallerID(CallerId: ID!): [incidentData]
}

type incidentData {
    number: String,
short_description: String
}

(function process(/*ResolverEnvironment*/ env) {
   
    var grIncident = new GlideRecord('incident');
    grIncident.addQuery('caller_id', env.getArguments().CallerId);
    grIncident.query();
    return grIncident;
})(env);
(function process(/*ResolverEnvironment*/ env) {
    
    var grIncident = new GlideRecord('incident');
    grIncident.addQuery('caller_id', env.getArguments().CallerId);
    grIncident.query();
    return grIncident;
})(env);​

 

 

Path : Query:getIncidentByCallerId
Resolver : IncidentByCallerId

Thank you for your help.

 

0 REPLIES 0