This project is a simple Django-based GraphQL API that manages information about countries and cities, developed to evaluate backend development skills.
- Python 3.x
- Django 3.x
- GraphQL
- SQLite
- Clone the repository
- Install dependencies with
pip install -r requirements.txt
. - Run migrations:
python manage.py migrate
. - Start the development server
python manage.py runserver
.
trendioexercise/
- Django project settings and configuration.geography/
- Main app, containing: models, GraphQL schemas, and views.
To interact with the GraphQL API, use the endpoint /graphql
.
- Here's an example query to get a list of all countries and their cities:
query {
allCountries {
id
name
citySet {
id
name
}
}
}
- The query can be filtered by country name:
query {
countryByName(name: "YourCountryName") {
id
name
}
}
- And new countries
mutation {
createCountry(input: { name: "YourCountryName" }) {
country {
id
name
}
}
}
or cities can be added:
mutation {
createCity(input: { name: "YourCityName", countryId: 1 }) {
city {
id
name
country {
id
name
}
}
}
}