an SMS management API
NodeJS, GraphQL, ExpressJS, Postgraphille, Postgres
The following software are required to run this app:
- NodeJS
- Node Package Manager (npm)
- Postgres - Database
Start local development using the following steps:
- Clone the repository locally
- setup a local
postgres
database - clone the
env.sample
file and rename it to.env
- replace default
.env
variables with yours if neccessary - run
npm install
to install node packages - run
export NODE_ENV=development && npm run db:prepare
to seed and migrate your database - Run
npm run start:dev
to start up the application - access the application via http at localhost:3000
This application can be tested locally by running npm test
All documentations can be obtained on the graphql api itself
local development docs localhost:3000
-
Queries
-
Find All
-
Contacts example
- query
query { allContacts { nodes { id, name, phone, createdAt, updatedAt, shortMessagesBySenderId { nodes { senderId, recieverId } }, shortMessagesByRecieverId { nodes { id, senderId, recieverId, message, status, createdAt, updatedAt } } } } }
- query
-
Sms example
- query
query { allShortMessages { nodes { id, senderId, recieverId, message, status, createdAt, updatedAt } } }
- query
-
-
Find By Id
-
Contacts example
- query
query($contactId: Int!) { contactById(id: $contactId) { id, name, phone, createdAt, shortMessagesBySenderId { nodes { id, senderId, contactBySenderId { name } } } } }
- query variables
"contactId": 1
-
-
Sms example
-
query
query($smsId: Int!) { shortMessageById(id: $smsId) { id, senderId, recieverId, message, status, createdAt, updatedAt, } }
-
query variables
"smsId": 1
-
-
-
Mutations
-
Create
-
Contacts example
- mutation
mutation($contact: CreateContactInput!) { createContact(input: $contact) { contact { id, name, phone, createdAt, updatedAt } } }
- argument variables
{ "contact": { "contact": { "name": "enogwe", "phone": "02233233232" } } }
- mutation
-
Sms example
- mutation
mutation($sms: CreateShortMessageInput!) { createShortMessage(input: $sms) { shortMessage { id, senderId, recieverId, message, status, createdAt, contactByRecieverId { id, name, nodeId }, contactBySenderId { id, name, phone } } } }
- query variables
"sms": { "shortMessage": { "senderId": 4, "recieverId": 4, "message": "hello world" } }
- mutation
-
-
Delete
-
Contacts example
-
mutation
mutation($contactId: DeleteContactByIdInput!) { deleteContactById(input: $contactId) { deletedContactId } }
-
query variables
"contactId": { "id": 5 }
-
-
-
To contribute, fork this repository, make required changes and open a pull request.