Git Product home page Git Product logo

graphql-pynamodb's People

Contributors

yfilali avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

graphql-pynamodb's Issues

DateTime format not ISO 8601

I realized that the date format in the results for a UTCDateTimeAttribute field for a pynamodb model was being sent on the results as '2021-06-07 17:40:59.538481+00:00' notice this is not ISO 8601 format which is used in JavaScript and commonly used in web applications.

https://github.com/yfilali/graphql-pynamodb/blob/master/graphene_pynamodb/converter.py#L30

Changing the code in the above line to instead of converting to String it converts to DateTime, will make the output of the datetime attribute to be output in ISO format.

Digging around I noticed there was this issue in graphene: graphql-python/graphene#136 which is very similar to this but it was addressed in graphene. If I understand correctly they suggested creating a custom DateTime graphene scalar type, but then went ahead and introduced the new scalar in the library.

I can submit a PR if needed, I just don't know if this would be the optimal solution.

Travis CI access to a dynamodb database

Locally, all the tests are running against a local dynamodb database. This is not possible with Travis CI right now so I need to change this to run against DynamoDB in AWS with credentials encrypted into .travis.yml

Model object has no attribute 'scan'

I'm attempting to setup the example and when using a resolver against a model declared from:
pynamodb.models import Model

I'm getting type object 'User' has no attribute 'scan'

Have you seen this before?

Supporting Model Subclasses

I noticed that Model subclasses were not supported. I did a hack in types.py:construct_fields() function to walk the Model's subclasses as well as the Model class itself. It seems to work. It is just a couple lines to modify. Just wanted to note this in case someone else hits this issue.

Thanks for all the work!
Jae

Add some support to composite field!?

I can define composite field like this:

class Composite(MapAttribute):
    a = UnicodeAttribute()
    b = NumberAttribute()

class MyModel(Model):
    composite = Comosite()

@convert_pynamo_attribute.register(Composite)
def convert_composite_field_to_object_type(type, attribute, registry=None):
    class _CompositeType(ObjectType):
        a = String()
        b = Int()

    return Field(_CompositeType, description=attribute.attr_name)

class CaseSchema(PynamoObjectType):
    class Meta:
        model = MyModel
        interfaces = (Node,)

or, add a more elegant and easy way to generate the _CompositeType class from Composite?

ListAttribute and MapAtrribute Support

I got the following exception when a try to use with PynamoDB ListAttribute and MapAttribute:

Exception: Don't know how to convert the PynamoDB attribute <pynamodb.attributes.ListAttribute object>

Scan vs Query based on params

At the moment, get_query just returns scan. The normal params (first, after, last, etc.) are not translated to the dynamodb equivalents.

OneToMany issue

Hi @yfilali
I have an issue with OneToMany relation, please check this code:
In my Pynamo model, I have

...
    menus = OneToMany('MenuModel', default=list)
...

in a mutation i have

 ChefModel(
            id=chef_id
        ).update(actions=[
            ChefModel.menus.set(ChefModel.menus.append([menu_item]))
        ])

sometimes I get this error:
'list' object has no attribute 'set'
on
ChefModel.menus.set(ChefModel.menus.append([menu_item]))

do you have an idea?
This happens after I assign to an instance of ChefModel.menu a list in another and totally disjointed part of the code.


response = [..some data here.]
chef.menus = response.menus
return chef

Handle relationships

Since dynamodb doesn't have relationships, it may be beneficial to add an example or a default implementation of relationships using dynamodb.

Circular Dependencies

Hi - First of all thanks for working on graphql-pynamodb!!

I'm having an issue with circular dependencies. I have a People table with people in it, some people may have other People as account_managers, some People may have other People as Dependent. I tried different ways such as:

class People(Model):
    class Meta:
        table_name = 'flask_pynamodb_example_people'
        host = "http://localhost:8000"

    id = UnicodeAttribute(hash_key=True)
    name = UnicodeAttribute()
    joined_at = UTCDateTimeAttribute(default=datetime.now)

class Dependent(People):
    class Meta:
        table_name = 'flask_pynamodb_example_people'
        host = "http://localhost:8000"

    account_managers = OneToMany(AccountManager)


class AccountManager(People):
    class Meta:
        table_name = 'flask_pynamodb_example_people'
        host = "http://localhost:8000"

    dependents = OneToMany(Dependent)

or:

class People(Model):
    class Meta:
        table_name = 'flask_pynamodb_example_people'
        host = "http://localhost:8000"

    id = UnicodeAttribute(hash_key=True)
    name = UnicodeAttribute()
    joined_at = UTCDateTimeAttribute(default=datetime.now)
    dependents = OneToMany(People)
    account_managers = OneToMany(People)

And neither work because of circular dependencies. Is this something that can be done, how? Thanks!

examples are not working

I am getting this error for default query

{
"errors": [
{
"message": "connection_resolver() takes exactly 8 arguments (6 given)",
"locations": [
{
"column": 3,
"line": 2
}
]
}
],

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.