- Clone this repo to your local directory
- Enable python virtual environment in the source directory
- Run
pip3 install -r requirements.txt
to install all the required packages - Run
python3 manage.py makemigrations
- Go to graph_api.schema and replace the api_key = "" with your api key
- Run
python3 manage.py migrate
- Run
python3 manage.py migrate --run-syncdb
- Create a super user for securing the api
python3 manage.py createsuperuser
and follow the prompts - Run
python3 manage.py migrate loaddata dummy.json
- Run
python3 manage.py runserver
to start the server at https://127.0.01/8000
The program when started runs locally on port 8000. This opens an admin page that'll require a login.
Navigate to https://127.0.01/8000/admin/graphql in your browser to access a graphiql user interface.
query getCustomers{ customers{ code name orders{ item amount } } }
query getOrders{ orders{ item amount time } }
mutation createOrder { createOrder(input: {item: "Tortillas", amount: 200, time: 2300}) { ok order { item amount time } } }
mutation createCustomer {
createCustomer(input: {code: 714044854, name: "Tom Hanks", orders: [{id: 1}, {id: 2}]}) {
ok
customer {
code
orders {
id
item
amount
time
}
}
}
}
In your project's root directory, rename .env.sample to .env and fill in the variable names with the corresponding values from Africastalking SDK
When the mutation for creating a new customer having a particular order is run, the api automatically takes the code, user's phone numner and sends an order complete message