Skip to content

Commit

Permalink
Merge pull request #8 from yefeza/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
yefeza authored Jun 10, 2023
2 parents f4aade9 + c77dfe6 commit 870343e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,5 @@ Release Notes
----------------------------

* Version 1.0.0 to 1.1.5 was a package developed for a specific project, and the code was not published on GitHub. The code was refactored and published on GitHub on version 1.2.0.
* Version 1.2.3 add support to set custom attributes on the model Type and set custom ordering field for the queries.
* Version 1.2.3 add support to set custom attributes on the model Type and set custom ordering field for the queries.
* Version 1.2.4 Fix custom attributes on the model Type.
6 changes: 3 additions & 3 deletions src/django_graphbox/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ def add_model(self, model, exclude_fields=(), pagination_length=0, pagination_st
model_name = model.__name__
#crreate the model type
model_metaclass = type(f"Meta", (), {'model': model, 'exclude_fields': exclude_fields})
model_type = type(f"{model_name}Type", (DjangoObjectType,), {'Meta': model_metaclass})
#add custom attributes to the model type
type_attrs={'Meta': model_metaclass}
for attr in custom_attrs_for_type:
setattr(model_type, attr['name'], attr['value'])
type_attrs[attr['name']]=attr['value']
model_type = type(f"{model_name}Type", (DjangoObjectType,), type_attrs)
#create paginated type
if pagination_length > 0 and pagination_style == 'paginated':
paginated_type = type(f"{model_name}PageType", (graphene.ObjectType,), {'items': graphene.List(model_type), 'page': graphene.Int(), 'has_next_page': graphene.Boolean(), 'has_previous_page': graphene.Boolean(), 'total_pages': graphene.Int(), 'total_items': graphene.Int()})
Expand Down

0 comments on commit 870343e

Please sign in to comment.