apix-core


Nameapix-core JSON
Version 0.0.10 PyPI version JSON
download
home_pagehttps://apix.org
SummaryapiX - The Python framework to create MongoDB-backed applications with GraphQL API web interface.
upload_time2023-08-10 15:41:07
maintainer
docs_urlNone
authorDanijel Kivaranovic
requires_python>=3.11,<4.0
licenseMIT
keywords graphql mongodb api starlette async
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
[<img src="https://www.apix.org/apix-logo-dark-mode.png" height="200">](https://apix.org)



---

**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](https://www.mongodb.com): The schemaless and document-oriented database is ideal to effortlessly create powerful applications from scratch.
- [GraphQL](https://graphql.org): The query language for APIs is perfectly suited to create efficient and well-documented APIs.
- [Google Cloud Storage](https://cloud.google.com/storage): The powerful object storage from Google allows you store data of any size and format.

## Installation

The **apiX** library is published on [PyPI](https://pypi.org/project/apix-core/) and can be installed with the following pip command.

```commandline
pip install apix-core
```

You can use [Uvicorn](https://www.uvicorn.org) to run the application. Uvicorn is an ASGI web server implementation for Python. To install apiX together with uvicorn run this pip command.

```commandline
pip install 'apix-core[uvicorn]'
```

## Documentation

Go to our website [apix.org](https://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.

```python 
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](https://insomnia.rest) or [Postman](https://www.postman.com)) 
and create a user with the following request.

```graphql
mutation {
    createUser(
        user: {
            name: "Dan"
            age: 30
        }
    ) {
        id
        name
        age
    }
}
```

To search for the user by name you can use the request below.

```graphql
query {
    findUserByName(
        name: "Dan"
    ) {
        id
        name
        age
    }
}
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://apix.org",
    "name": "apix-core",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11,<4.0",
    "maintainer_email": "",
    "keywords": "graphql,mongodb,api,starlette,async",
    "author": "Danijel Kivaranovic",
    "author_email": "dan@apix.org",
    "download_url": "https://files.pythonhosted.org/packages/0c/b8/cd52a82acb069b01705868c6acc19ed99032bd3a53e1356f74bc14299fd1/apix_core-0.0.10.tar.gz",
    "platform": null,
    "description": "\n[<img src=\"https://www.apix.org/apix-logo-dark-mode.png\" height=\"200\">](https://apix.org)\n\n\n\n---\n\n**Documentation**: https://apix.org\n\n**Source Code**: https://github.com/ApixOrg/apix\n\n---\n\n**apiX** is a full-stack framework for backend developlment. **apiX** integrates all necessary components to create \npowerful backend applications in Python with just a few lines of code. Use **apiX** to create with ease \n-backed applications with a [GraphQL]() API . \n\n## Integrated technologies\n\n- [MongoDB](https://www.mongodb.com): The schemaless and document-oriented database is ideal to effortlessly create powerful applications from scratch.\n- [GraphQL](https://graphql.org): The query language for APIs is perfectly suited to create efficient and well-documented APIs.\n- [Google Cloud Storage](https://cloud.google.com/storage): The powerful object storage from Google allows you store data of any size and format.\n\n## Installation\n\nThe **apiX** library is published on [PyPI](https://pypi.org/project/apix-core/) and can be installed with the following pip command.\n\n```commandline\npip install apix-core\n```\n\nYou can use [Uvicorn](https://www.uvicorn.org) to run the application. Uvicorn is an ASGI web server implementation for Python. To install apiX together with uvicorn run this pip command.\n\n```commandline\npip install 'apix-core[uvicorn]'\n```\n\n## Documentation\n\nGo to our website [apix.org](https://apix.org) and check out the detailed documentation.\n\n## Example App\n\nMake sure that you have **apiX** and **uvicorn** installed. Before you run the python code, replace the CONNECTION_STRING placeholder\nwith the connection string to your MongoDB instance.\n\n```python \nimport uvicorn\nfrom apix.app import ApixApp\nfrom apix.attribute import ApixIntegerAttribute, ApixStringAttribute\nfrom apix.database import ApixDatabase\nfrom apix.model import ApixModel\nfrom apix.resolver import ApixMutationResolver, ApixQueryResolver\nfrom apix.scalar import ApixString\n\n\n# Connection details of your MongoDB instance\nDatabase = ApixDatabase(\n    host='CONNECTION_STRING',\n    name='demo',\n)\n\n\n# User model definition\nUser = ApixModel(\n    name='user',\n    attributes=[\n        ApixStringAttribute('name'),\n        ApixIntegerAttribute('age'),\n    ],\n)\n\n\n# Function to create a user\ndef create_user(user: User) -> User:\n    Database(User).insert_one(user)\n    return user\n\n\n# Function to find a user by name\ndef find_user_by_name(name: ApixString) -> User:\n    return Database(User).find_one(User.Name.Equal(name))\n\n\n# Create the app\napp = ApixApp(\n    resolvers=[\n        ApixMutationResolver(create_user),\n        ApixQueryResolver(find_user_by_name),\n    ],\n)\n\nif __name__ == '__main__':\n    uvicorn.run(\n        app=app,\n        host='localhost',\n        port=8080,\n    )\n\n```\n\nOnce your app is running, the GraphQL API is available at [http://localhost:8080/graphql](). Now open your favorite web client (such as [Insomnia](https://insomnia.rest) or [Postman](https://www.postman.com)) \nand create a user with the following request.\n\n```graphql\nmutation {\n    createUser(\n        user: {\n            name: \"Dan\"\n            age: 30\n        }\n    ) {\n        id\n        name\n        age\n    }\n}\n```\n\nTo search for the user by name you can use the request below.\n\n```graphql\nquery {\n    findUserByName(\n        name: \"Dan\"\n    ) {\n        id\n        name\n        age\n    }\n}\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "apiX - The Python framework to create MongoDB-backed applications with GraphQL API web interface.",
    "version": "0.0.10",
    "project_urls": {
        "Documentation": "https://apix.org",
        "Homepage": "https://apix.org",
        "Repository": "https://github.com/ApixOrg/apix"
    },
    "split_keywords": [
        "graphql",
        "mongodb",
        "api",
        "starlette",
        "async"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "78446484f4ab39cb8e4c95f4beb422b9f61f56326bccb49ac6bf2e50eb349ea8",
                "md5": "bba187efd2ba1ce68a4c6ac44d320b29",
                "sha256": "805121ff361dd80317a33e8a8f4340d60e60622f053ba03be193b7399de48bd8"
            },
            "downloads": -1,
            "filename": "apix_core-0.0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bba187efd2ba1ce68a4c6ac44d320b29",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11,<4.0",
            "size": 36501,
            "upload_time": "2023-08-10T15:41:06",
            "upload_time_iso_8601": "2023-08-10T15:41:06.029284Z",
            "url": "https://files.pythonhosted.org/packages/78/44/6484f4ab39cb8e4c95f4beb422b9f61f56326bccb49ac6bf2e50eb349ea8/apix_core-0.0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0cb8cd52a82acb069b01705868c6acc19ed99032bd3a53e1356f74bc14299fd1",
                "md5": "f67e5c6b225a9a011f671dd793a25814",
                "sha256": "4f0068740164946c2b26b094c855442740d03026617a7bb9031f43864d6f1d89"
            },
            "downloads": -1,
            "filename": "apix_core-0.0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "f67e5c6b225a9a011f671dd793a25814",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11,<4.0",
            "size": 25405,
            "upload_time": "2023-08-10T15:41:07",
            "upload_time_iso_8601": "2023-08-10T15:41:07.992580Z",
            "url": "https://files.pythonhosted.org/packages/0c/b8/cd52a82acb069b01705868c6acc19ed99032bd3a53e1356f74bc14299fd1/apix_core-0.0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-10 15:41:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ApixOrg",
    "github_project": "apix",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "apix-core"
}
        
Elapsed time: 0.22467s