apiX - The Python framework to create MongoDB-backed applications with GraphQL API web interface.
Project description
Documentation: https://apix.org
Source Code: https://github.com/ApixOrg/apix
apiX is a full-stack framework for backend developlment. apiX integrates all necessary components to create powerful backend applications in Python with just a few lines of code. Use apiX to create with ease -backed applications with a GraphQL API .
Integrated technologies
- MongoDB: The schemaless and document-oriented database is ideal to effortlessly create powerful applications from scratch.
- GraphQL: The query language for APIs is perfectly suited to create efficient and well-documented APIs.
- Google Cloud Storage: The powerful object storage from Google allows you store data of any size and format.
Installation
The apiX library is published on PyPI and can be installed with the following pip command.
pip install apix-core
You can use Uvicorn to run the application. Uvicorn is an ASGI web server implementation for Python. To install apiX together with uvicorn run this pip command.
pip install 'apix-core[uvicorn]'
Documentation
Go to our website apix.org and check out the detailed documentation.
Example App
Make sure that you have apiX and uvicorn installed. Before you run the python code, replace the CONNECTION_STRING placeholder with the connection string to your MongoDB instance.
import uvicorn
from apix.app import ApixApp
from apix.attribute import ApixIntegerAttribute, ApixStringAttribute
from apix.database import ApixDatabase
from apix.model import ApixModel
from apix.resolver import ApixMutationResolver, ApixQueryResolver
from apix.scalar import ApixString
# Connection details of your MongoDB instance
Database = ApixDatabase(
host='CONNECTION_STRING',
name='demo',
)
# User model definition
User = ApixModel(
name='user',
attributes=[
ApixStringAttribute('name'),
ApixIntegerAttribute('age'),
],
)
# Function to create a user
def create_user(user: User) -> User:
Database(User).insert_one(user)
return user
# Function to find a user by name
def find_user_by_name(name: ApixString) -> User:
return Database(User).find_one(User.Name.Equal(name))
# Create the app
app = ApixApp(
resolvers=[
ApixMutationResolver(create_user),
ApixQueryResolver(find_user_by_name),
],
)
if __name__ == '__main__':
uvicorn.run(
app=app,
host='localhost',
port=8080,
)
Once your app is running, the GraphQL API is available at http://localhost:8080/graphql. Now open your favorite web client (such as Insomnia or Postman) and create a user with the following request.
mutation {
createUser(
user: {
name: "Dan"
age: 30
}
) {
id
name
age
}
}
To search for the user by name you can use the request below.
query {
findUserByName(
name: "Dan"
) {
id
name
age
}
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file apix_core-0.0.10.tar.gz
.
File metadata
- Download URL: apix_core-0.0.10.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f0068740164946c2b26b094c855442740d03026617a7bb9031f43864d6f1d89 |
|
MD5 | f67e5c6b225a9a011f671dd793a25814 |
|
BLAKE2b-256 | 0cb8cd52a82acb069b01705868c6acc19ed99032bd3a53e1356f74bc14299fd1 |
File details
Details for the file apix_core-0.0.10-py3-none-any.whl
.
File metadata
- Download URL: apix_core-0.0.10-py3-none-any.whl
- Upload date:
- Size: 36.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 805121ff361dd80317a33e8a8f4340d60e60622f053ba03be193b7399de48bd8 |
|
MD5 | bba187efd2ba1ce68a4c6ac44d320b29 |
|
BLAKE2b-256 | 78446484f4ab39cb8e4c95f4beb422b9f61f56326bccb49ac6bf2e50eb349ea8 |