Giter VIP home page Giter VIP logo

alchemy_graph's Introduction

๐Ÿ”บ alchemy_graph ๐Ÿ”บ

photo_2023-05-26_16-50-36

SQLAlchemy mapper to Strawberry types

โœ๏ธ Installation

You can install mapper using pip:

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.

alchemy_graph's People

Contributors

kieled avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.