Built with Node.JS, Express, the express-graphql package and the promise-mysql package.
- Firstly clone this repo locally
- Run
npm install
to install the project dependencies - Create a new DB callled
core_questions_db
and run the SQL filecore_questions_db.sql
to create the schema and add some sample data - Run
node index.js
ornodemon index.js
to start the application
You should then be able to access the GraphiQL UI by visting http://localhost:4009/graphql
Full documentation is generated by the GraphiQL UI which can be accessed by visting http://localhost:4009/graphql
query {
singleQuestion (q_id: 3) {
q_id
question
gp_order
}
}
{
"data": {
"singleQuestion": {
"q_id": 3,
"question": "I have felt ok about myself",
"gp_order": 3
}
}
}
query {
allQuestions {
q_id
question
}
}
{
"data": {
"allQuestions": [
{
"q_id": 1,
"question": "I have felt tense, anxious or nervous"
},
{
"q_id": 2,
"question": "I have felt I have someone to turn to for support when needed"
},
{
"q_id": 3,
"question": "I have felt ok about myself"
},
{
"q_id": 4,
"question": "I have felt able to cope when things go wrong"
},
{
"q_id": 5,
"question": "I have been troubled by aches, pains or other physical problems\t"
},
{
"q_id": 6,
"question": "I have been happy with the things I have done"
},
{
"q_id": 7,
"question": "I have had difficulty getting to sleep or staying asleep"
},
{
"q_id": 8,
"question": "I have felt warmth or affection for someone"
},
{
"q_id": 9,
"question": "I have been able to do most things I needed to"
},
{
"q_id": 10,
"question": "I have felt criticised by other people"
},
{
"q_id": 11,
"question": "I have felt unhappy"
},
{
"q_id": 12,
"question": "I have been irritable when with other people"
},
{
"q_id": 13,
"question": "I have felt optimistic about my future"
},
{
"q_id": 14,
"question": "I have achieved the things I wanted to"
}
]
}
}
query {
allScaleLabels {
scale_id
label
}
}
{
"data": {
"allScaleLabels": [
{
"scale_id": 1,
"label": "Not at all"
},
{
"scale_id": 2,
"label": "Only occasionally"
},
{
"scale_id": 3,
"label": "Sometimes"
},
{
"scale_id": 4,
"label": "Often"
},
{
"scale_id": 5,
"label": "Most or All the time"
}
]
}
}
query {
allQuestionsAndPoints {
q_id
question
points_type
pointsA_not
pointsB_only
pointsC_sometimes
pointsD_often
pointsE_most
}
}
{
"data": {
"allQuestionsAndPoints": [
{
"q_id": 1,
"question": "I have felt tense, anxious or nervous",
"points_type": 123,
"pointsA_not": 0,
"pointsB_only": 1,
"pointsC_sometimes": 2,
"pointsD_often": 3,
"pointsE_most": 4
},
{
"q_id": 2,
"question": "I have felt I have someone to turn to for support when needed",
"points_type": 321,
"pointsA_not": 4,
"pointsB_only": 3,
"pointsC_sometimes": 2,
"pointsD_often": 1,
"pointsE_most": 0
},
{
"q_id": 3,
"question": "I have felt ok about myself",
"points_type": 321,
"pointsA_not": 4,
"pointsB_only": 3,
"pointsC_sometimes": 2,
"pointsD_often": 1,
"pointsE_most": 0
},
{
"q_id": 4,
"question": "I have felt able to cope when things go wrong",
"points_type": 321,
"pointsA_not": 4,
"pointsB_only": 3,
"pointsC_sometimes": 2,
"pointsD_often": 1,
"pointsE_most": 0
},
{
"q_id": 5,
"question": "I have been troubled by aches, pains or other physical problems",
"points_type": 123,
"pointsA_not": 0,
"pointsB_only": 1,
"pointsC_sometimes": 2,
"pointsD_often": 3,
"pointsE_most": 4
},
{
"q_id": 6,
"question": "I have been happy with the things I have done",
"points_type": 321,
"pointsA_not": 4,
"pointsB_only": 3,
"pointsC_sometimes": 2,
"pointsD_often": 1,
"pointsE_most": 0
},
{
"q_id": 7,
"question": "I have had difficulty getting to sleep or staying asleep",
"points_type": 123,
"pointsA_not": 0,
"pointsB_only": 1,
"pointsC_sometimes": 2,
"pointsD_often": 3,
"pointsE_most": 4
},
{
"q_id": 8,
"question": "I have felt warmth or affection for someone",
"points_type": 321,
"pointsA_not": 4,
"pointsB_only": 3,
"pointsC_sometimes": 2,
"pointsD_often": 1,
"pointsE_most": 0
},
{
"q_id": 9,
"question": "I have been able to do most things I needed to",
"points_type": 321,
"pointsA_not": 4,
"pointsB_only": 3,
"pointsC_sometimes": 2,
"pointsD_often": 1,
"pointsE_most": 0
},
{
"q_id": 10,
"question": "I have felt criticised by other people",
"points_type": 123,
"pointsA_not": 0,
"pointsB_only": 1,
"pointsC_sometimes": 2,
"pointsD_often": 3,
"pointsE_most": 4
},
{
"q_id": 11,
"question": "I have felt unhappy",
"points_type": 123,
"pointsA_not": 0,
"pointsB_only": 1,
"pointsC_sometimes": 2,
"pointsD_often": 3,
"pointsE_most": 4
},
{
"q_id": 12,
"question": "I have been irritable when with other people",
"points_type": 123,
"pointsA_not": 0,
"pointsB_only": 1,
"pointsC_sometimes": 2,
"pointsD_often": 3,
"pointsE_most": 4
},
{
"q_id": 13,
"question": "I have felt optimistic about my future",
"points_type": 321,
"pointsA_not": 4,
"pointsB_only": 3,
"pointsC_sometimes": 2,
"pointsD_often": 1,
"pointsE_most": 0
},
{
"q_id": 14,
"question": "I have achieved the things I wanted to",
"points_type": 321,
"pointsA_not": 4,
"pointsB_only": 3,
"pointsC_sometimes": 2,
"pointsD_often": 1,
"pointsE_most": 0
}
]
}
}