yfilali / graphql-pynamodb Goto Github PK
View Code? Open in Web Editor NEWGraphene PynamoDB Integration
License: MIT License
Graphene PynamoDB Integration
License: MIT License
I have good coverage for some types and the converters. I'd like to see more tests using the full set of attribute types that DynamoDB supports
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.
Hi guys, when we can expect to use graphql-pynamodb with pynamodb > 3.0.0 (ie. 3.3.1)?
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
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?
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
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?
When converting a table with a NumberAttribute it becomes an INT instead of a Float
https://github.com/yfilali/graphql-pynamodb/blob/master/graphene_pynamodb/converter.py#L57
See graphql-python/flask-graphql#44
How would one document his graphiql mutations etc ?
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>
At the moment, get_query just returns scan. The normal params (first, after, last, etc.) are not translated to the dynamodb equivalents.
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
Since dynamodb doesn't have relationships, it may be beneficial to add an example or a default implementation of relationships using dynamodb.
Any idea when there will be support for PynamoDB 4?
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!
I am getting this error for default query
{
"errors": [
{
"message": "connection_resolver() takes exactly 8 arguments (6 given)",
"locations": [
{
"column": 3,
"line": 2
}
]
}
],
Looks like only graphene <2.0 is supported. Is there any plan to support 2.x in the near future?
Thanks,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.