0soft / graphene-django-plus Goto Github PK
View Code? Open in Web Editor NEWTools to easily create permissioned CRUD endpoints in graphene.
License: MIT License
Tools to easily create permissioned CRUD endpoints in graphene.
License: MIT License
Hello, I have a model that has a "owner" field with it.
I have two questions:
Looking forward to your reply.
Make relay interface optional for people who doesn't want to use relay.
I really like how you have constructed the serializer mutations. It would be nice to have "RelaySerializerMutation" like this in graphene-django. The permissions are a nice touch as well. Any reason why this is a separate project? Is there a long term goal of making this part of graphene-django?
When using without django-guardian, an exception is raised due to type hints using ObjectPermissionChecker, which is not imported.
Good day.
Thank you very much for the library, we're using this in our company for a while! Will try to share our findings and suggestions as we use it.
What we've spotted after the latest release is that while releasing 2.0 version (3582a6f) check for object permissions from ObjectType
class was deleted. Currently I can spot the following issues:
check_object_permissions
function is still there, but as far as I understand it's not used anymore, right? (https://github.com/0soft/graphene-django-plus/blob/master/graphene_django_plus/types.py#L181) This creates a little confusion and even more with the description of this functionWhat I'd suggest is since you're already checking permissions of a GuardianModel, maybe this function can be left as a placeholder for extra permission logic? As same as before_save
and after_save
methods from graphene
library with a simple pass
line?
What are your ideas on this guys? Does that make sense?
Looking at the releases the latest release was 2 weeks ago.
However this pinned issue explicitly states that it's deprecated.
So, which is it?
AFAIK one of the dependencies used, graphene-django-optimizer, is deprecated (last update 2+ years ago) and is not compatible with Django 4.
First of all, I would like to thank you for piece of good work. Inspired by @mirumee guys, I wanted to write something similar, but found your library.
I like to keep the following Django application structure:
books
├── models.py
├── mutations.py
├── schema.py
└── types.py
In schema I put everything together. I noticed when types are imported after mutations:
from .mutations import BookCreateMutation, BookUpdateMutation
from .types import BookType
Django/Graphene throws the following exception:
django.core.exceptions.ImproperlyConfigured: Unable to find type for model Book in graphene registry
When types
are imported before mutations
application starts normally. This is a little problematic because isort
changes the order, which makes it necessary to disable sorting in all my schema.py
files.
I haven't had time to dig into your code, but maybe you can tell me the potential cause of my problem?
For example, say you have two models (Just psuedocode)
class Father(models.Model):
name = CharField(max_length=256, db_index=True)
class Son(models.Model):
name = CharField(max_length=256, db_index=True)
father = ForeignKey(Father, on_delete=CASCADE, related_name='sons')
And then my update mutation object would look something like this -
class UpdateFather(ModelUpdateMutation):
class Meta:
model = Father
For updates, I would like to attach or link sons to father when I update a father.
This is currently not possible because BaseModelMutation calls _get_fields which does not handle model._meta.related_objects and ManyToOne fields. So the schema never gets the reverse ManyToOne field included as a list of IDs in the input argument.
Support of handling reverse relationships is highly useful, it will support UI workflows similar to how the admin UI can support creating and linking child models to parent while updating the parent.
I have a issue in a project. Is throwing me: Don't know how to convert the Django field aerio.Grupo.id (<class 'django.db.models.fields.UUIDField'>)
Checking, my doubt is: Why UUID
is phone
:
Hey, guys... I need your help.
How I can test a mutations with UploadType.
Our model Post
class Post(Resource):
image = models.ImageField(upload_to="post")
And my Test
class PostTestCase(JSONWebTokenTestCase):
def setUp(self):
self.post = PostFactory
def test_create(self):
post = self.post.build()
query = '''
mutation($input: PostCreateInput!) {
postCreate(input: $input) {
post{
id
image
}
}
}
'''
response = self.client.post(
'/graphql',
data={
'operations': json.dumps({
'query': query,
'variables': {
'input': {
'image': None
},
},
}),
't_file': post.image,
'map': json.dumps({
't_file': ['variables.input.image'],
}),
}
)
print(response)
And the response
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
<WSGIRequest: POST '/graphql'>
.
----------------------------------------------------------------------
Ran 1 test in 0.087s
OK
Destroying test database for alias 'default'...
The file doesn't upload!
Django discourages the use of null=True for CharFields (and other fields based on CharField, like URLField etc) - https://docs.djangoproject.com/en/3.0/ref/models/fields/#null.
But the mutation types generates required input parameters for such fields. It should look at the 'blank' property of the field for CharField and TextField to decide if it's required or not.
Hi,
I have notice that inside get_node method in ModelType class before check permission at this point is not checked if cls has a object_permissions attribute inside Meta class.
it's right ?
Thanks for the attention and the job for the library :)
The last pipeline of my project worked correctly. This was two weeks ago. This week there have been several problems with this library. Now it is throwing me this error: 'FloatField' object has no attribute 'max_digits'
For Django Float and Decimal are different: https://github.com/0soft/graphene-django-plus/blob/master/graphene_django_plus/schema.py#L116-L117
Graphene itself is abandoned and most users are migrating to other better alternatives, like strawberry.
For that reason this lib is being deprecated and new features will no longer be developed for it. Maintenance is still going to happen and PRs are still welcomed though.
For anyone looking for alternatives, I created strawberry-django-plus to use not only as a migration path to the projects I maintain, but also to add even more awesome features. Be sure to check it out!
As I've installed new 2.3 release I've faces several issues, which firstly I want to bring up for a discussion and upon an approval - I could create a PR for fixing. Issues are as following:
class Father(models.Model):
name = CharField(max_length=256, db_index=True)
class Son(models.Model):
name = CharField(max_length=256, db_index=True)
father = ForeignKey(Father, on_delete=CASCADE)
As far as I've debugged - in case FK field does not have related_name
attribute it's not added as son_set
field either (I think it comes up from this line https://github.com/0soft/graphene-django-plus/blob/master/graphene_django_plus/mutations.py#L97). I believe this can bring a very big confuse as Django does not force you to put related_name
attribute
2. Basically now by default related son objects can be assigned to Father
(following the previous example) while you wouldn't even think about that since it's not directly in the model when creating a mutation, right?I believe this might bring some logic-related security issues for some projects. What I'd suggest is that this possibility is really great, but I'd expect that to be added only when I explicitly add related_name in fields of mutation:
class UpdateFather(ModelUpdateMutation):
class Meta:
model = Father
only_fields = ["name", "sons"] # While it wouldn't be possible to update sons relation in case it's not in `only_fields` (`only_fields` are not defined at all)
What are your ideas about that?
Can I use this package without relay interface?
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.