In my node js code
var express_graphql = require('express-graphql');
var { buildSchema } = require('graphql');
var schema = buildSchema(`
type Query {
getCandidateKey(email : String): GetCandidateKey
}
type GetCandidateKey{
CandidateID : Int
}
`);
here i am executing the stored procedure
var GetCandidateKey = async function (args) {
let email = args.email
let query = "exec getCandidateKey @EmailID='" + email + "';"; //executing stored procedures
const pool = await poolPromise
const result = await pool.request().query(query)
return result.recordset[0]
}
Root resolver
var root = {
getCandidateKey: GetCandidateKey,
};
Create an express server and a GraphQL endpoint
app.use('/graphql', express_graphql({
schema: schema,
rootValue: root,
graphiql: true
}));
The result i am getting
The result i want if query successfully execute
{
"status" : "success"
"data": {
"getCandidateKey": {
"CandidateID": 56
}
}
}
For any error
{
"status" : "error" //for throwing error
"data": null
}
P.S I am new to GraphQL and SQL Server.
