Giter Site home page Giter Site logo

graphene-django-plus's People

Contributors

bellini666 avatar dependabot[bot] avatar justinask7 avatar nietzscheson avatar parrotmac avatar rainerhausdorf avatar rainshaw avatar riros 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

graphene-django-plus's Issues

#support #UploadType

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!

Version 2.1 change breaks current object permissions

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:

  1. 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 function
  2. Was it really necessary to delete this function usage? Because it was quite useful for extra business logic permissions when trying to retrieve the object

What 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?

When and where to set some field value before mutation?

Hello, I have a model that has a "owner" field with it.

I have two questions:

  1. how can i make this field not required or even hidden on graphql api?
  2. how can i set it to the request user before save? or raise error when the both do not match if Q1 can not be solved.

Looking forward to your reply.

Order of imports affects the operation of the library

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?

Any plans on merging this functionality with graphene-django?

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?

Issues with new 2.3 release

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:

  1. Schema is unable to generate related fields in case they are not defined, I mean in case we have ForeignKey without related_name definition:
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?

This lib is DEPRECATED (read this)

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!

BaseModelMutation doesn't generate input fields for reverse foreign key relationships.

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.

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.