alchemy-graph


Namealchemy-graph JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/kieled/alchemy_graph
Summary
upload_time2023-07-07 23:01:46
maintainer
docs_urlNone
authorKiel Ed
requires_python>=3.10,<4.0
license
keywords strawberry-graphql sqlalchemy-mapper sqlalchemy strawberry mapper dict
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h2 align="center">:small_red_triangle: alchemy_graph :small_red_triangle:</h2>

![photo_2023-05-26_16-50-36](https://github.com/kieled/alchemy_graph/assets/68655454/ac2e2804-4cf3-4eea-942a-07fb4c5f0db2)

<p align="center">
    <a href="https://pypi.python.org/pypi/alchemy_graph" alt="PyPi Package Version">
        <img src="https://img.shields.io/pypi/v/alchemy_graph.svg" /></a>
    <a href="https://pypi.python.org/pypi/alchemy_graph" alt="Supported Python versions">
        <img src="https://img.shields.io/pypi/pyversions/alchemy_graph.svg" /></a>
    <a href="https://github.com/kieled/alchemy_graph/actions/workflows/test.yml" alt="GitFlow">
        <img src="https://github.com/kieled/alchemy_graph/actions/workflows/test.yml/badge.svg" /></a>
</p>

<p align="center">SQLAlchemy mapper to Strawberry types</p>


## :pencil2: Installation
You can install mapper using pip:

```bash
pip install alchemy-graph
```

## Functions:
### `get_only_selected_fields`
Given a SQLAlchemy model class and a Strawberry Info object representing a selection set, returns a SQLAlchemy Select object that loads only the fields and relations specified in the selection set.

#### Parameters:

- sqlalchemy_class: The SQLAlchemy model class to select fields from.
- info: The Strawberry Info object representing the selection set.
- inner_selection_name: The name of an inner selection set to consider. If specified, only fields and relations under this selection set will be included in the Select object.
#### Returns:
A SQLAlchemy Select object that loads only the specified fields and relations.
### `orm_to_strawberry`
Function maps sqlalchemy model to strawberry class.

#### Parameters:
- input_data: SqlAlchemy Base Model or list of base models.
- strawberry_type: Strawberry class wrapped in strawberry.input or strawberry.type.
#### Returns:
Strawberry objects or list of them.
### `strawberry_to_dict`
Given a Strawberry object and an optional list of allowed keys, returns a dictionary representation of the object.

#### Parameters:
- `obj`: A Strawberry object to convert to a dictionary.
- `allowed_keys`: An optional list of keys to include in the output dictionary. If not specified, all keys are included.
#### Returns:
A dictionary representation of the input object.
### `orm_mapper`
Function returns decorator for your Query strawberry.field().

#### Parameters:
- `strawberry_type`: Strawberry type that should be return. Required if result_to_strawberry=True.
- `inject_query`: Inject into current function SqlAlchemy Query. Default value: False.
- `sqlalchemy_class`: SqlAlchemy model class.
- `inner_selection_name`: The name of an inner selection set to consider. If specified, only fields and relations under this selection set will be included in the Select object.
- `result_to_strawberry`: If True, it returns Strawberry object(s). Default value: True.
### `get_dict_object`
Given an SQLAlchemy object, returns a dictionary representation of the object.

#### Parameters:
- `obj`: An SQLAlchemy object to convert to a dictionary.
#### Returns:
A dictionary representation of the input object.

## LICENSE

This project is licensed under the terms of the MIT license.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kieled/alchemy_graph",
    "name": "alchemy-graph",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "strawberry-graphql,sqlalchemy-mapper,sqlalchemy,strawberry,mapper,dict",
    "author": "Kiel Ed",
    "author_email": "kieledssh@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/5f/4c/fa23f4d679f2b2ea9e0dbd30ef42ef67b4e4305495b67dcb2b95c00d1ac0/alchemy_graph-0.1.3.tar.gz",
    "platform": null,
    "description": "<h2 align=\"center\">:small_red_triangle: alchemy_graph :small_red_triangle:</h2>\n\n![photo_2023-05-26_16-50-36](https://github.com/kieled/alchemy_graph/assets/68655454/ac2e2804-4cf3-4eea-942a-07fb4c5f0db2)\n\n<p align=\"center\">\n    <a href=\"https://pypi.python.org/pypi/alchemy_graph\" alt=\"PyPi Package Version\">\n        <img src=\"https://img.shields.io/pypi/v/alchemy_graph.svg\" /></a>\n    <a href=\"https://pypi.python.org/pypi/alchemy_graph\" alt=\"Supported Python versions\">\n        <img src=\"https://img.shields.io/pypi/pyversions/alchemy_graph.svg\" /></a>\n    <a href=\"https://github.com/kieled/alchemy_graph/actions/workflows/test.yml\" alt=\"GitFlow\">\n        <img src=\"https://github.com/kieled/alchemy_graph/actions/workflows/test.yml/badge.svg\" /></a>\n</p>\n\n<p align=\"center\">SQLAlchemy mapper to Strawberry types</p>\n\n\n## :pencil2: Installation\nYou can install mapper using pip:\n\n```bash\npip install alchemy-graph\n```\n\n## Functions:\n### `get_only_selected_fields`\nGiven a SQLAlchemy model class and a Strawberry Info object representing a selection set, returns a SQLAlchemy Select object that loads only the fields and relations specified in the selection set.\n\n#### Parameters:\n\n- sqlalchemy_class: The SQLAlchemy model class to select fields from.\n- info: The Strawberry Info object representing the selection set.\n- inner_selection_name: The name of an inner selection set to consider. If specified, only fields and relations under this selection set will be included in the Select object.\n#### Returns:\nA SQLAlchemy Select object that loads only the specified fields and relations.\n### `orm_to_strawberry`\nFunction maps sqlalchemy model to strawberry class.\n\n#### Parameters:\n- input_data: SqlAlchemy Base Model or list of base models.\n- strawberry_type: Strawberry class wrapped in strawberry.input or strawberry.type.\n#### Returns:\nStrawberry objects or list of them.\n### `strawberry_to_dict`\nGiven a Strawberry object and an optional list of allowed keys, returns a dictionary representation of the object.\n\n#### Parameters:\n- `obj`: A Strawberry object to convert to a dictionary.\n- `allowed_keys`: An optional list of keys to include in the output dictionary. If not specified, all keys are included.\n#### Returns:\nA dictionary representation of the input object.\n### `orm_mapper`\nFunction returns decorator for your Query strawberry.field().\n\n#### Parameters:\n- `strawberry_type`: Strawberry type that should be return. Required if result_to_strawberry=True.\n- `inject_query`: Inject into current function SqlAlchemy Query. Default value: False.\n- `sqlalchemy_class`: SqlAlchemy model class.\n- `inner_selection_name`: The name of an inner selection set to consider. If specified, only fields and relations under this selection set will be included in the Select object.\n- `result_to_strawberry`: If True, it returns Strawberry object(s). Default value: True.\n### `get_dict_object`\nGiven an SQLAlchemy object, returns a dictionary representation of the object.\n\n#### Parameters:\n- `obj`: An SQLAlchemy object to convert to a dictionary.\n#### Returns:\nA dictionary representation of the input object.\n\n## LICENSE\n\nThis project is licensed under the terms of the MIT license.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/kieled/alchemy_graph",
        "Repository": "https://github.com/kieled/alchemy_graph"
    },
    "split_keywords": [
        "strawberry-graphql",
        "sqlalchemy-mapper",
        "sqlalchemy",
        "strawberry",
        "mapper",
        "dict"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3ead13e891693b0ff6ac617980e73c17d84dd1941be0b5f39e8b4af741b48f77",
                "md5": "33549e6eb5e41eba937e0b2cddef3250",
                "sha256": "db1bcea2c92c45ed6557c30f15d29b2d20c2acd92d041e32a450903f61b3ab2a"
            },
            "downloads": -1,
            "filename": "alchemy_graph-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "33549e6eb5e41eba937e0b2cddef3250",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 6610,
            "upload_time": "2023-07-07T23:01:45",
            "upload_time_iso_8601": "2023-07-07T23:01:45.116097Z",
            "url": "https://files.pythonhosted.org/packages/3e/ad/13e891693b0ff6ac617980e73c17d84dd1941be0b5f39e8b4af741b48f77/alchemy_graph-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5f4cfa23f4d679f2b2ea9e0dbd30ef42ef67b4e4305495b67dcb2b95c00d1ac0",
                "md5": "d1dedb934ed64aefdee83900f89547ca",
                "sha256": "95d1671e4672d3f7c40b9d727d2325fc5be516e0eba58c9fd8f9281ad95395d3"
            },
            "downloads": -1,
            "filename": "alchemy_graph-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "d1dedb934ed64aefdee83900f89547ca",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 7747,
            "upload_time": "2023-07-07T23:01:46",
            "upload_time_iso_8601": "2023-07-07T23:01:46.429658Z",
            "url": "https://files.pythonhosted.org/packages/5f/4c/fa23f4d679f2b2ea9e0dbd30ef42ef67b4e4305495b67dcb2b95c00d1ac0/alchemy_graph-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-07 23:01:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kieled",
    "github_project": "alchemy_graph",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "alchemy-graph"
}
        
Elapsed time: 2.04283s