question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rest Framework SerializerMutation Error - NoneType is not callable

See original GitHub issue

Hi, I’m using the SerializerMutation class to attempt to create mutations based off of my existing Rest Framework serializers. By taking advantage of the ModelSerializer in DRF, I hoped to avoid having to create all the mutations from scratch with validation and whatnot.

However, the use of the SerializerMutation class isn’t sufficiently explained in the docs. I did this

class ItemMutation(SerializerMutation):
    class Meta:
        serializer_class = ItemSerializer

class Mutation(AbstractType):
    #...other mutations...
    createItem = ItemMutation.Field()

from a simple DRF ModelSerializer

class ItemSerializer(serializers.ModelSerializer):
    class Meta:
        model = Item
        fields = (
            'id',
            'name',
            'description',
            'website',
        )

But Graphiql shows me the following error whenever I try to use the mutation

mutation newItem($data: ItemMutationInput!) {
  createItem(input: $data) {
    name,
    description
  }
}

{
  "data": {
    "name": "Blah",
    "description": "Blah blah blah",
    "website": "https://blah.blah.blah"
  }
}
{
  "errors": [
    {
      "message": "'NoneType' object is not callable",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ]
    }
  ],
  "data": {
    "createItem": null
  }
}

Also, Rest Framework’s serializers can often have multiple actions (mutations) like create, delete, update, etc and the use of SerializerMutation appears to just produce a single mutation - presumably the “create” action. How do I handle the other actions?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
q3aimlcommented, Aug 31, 2017

@abdulhaq-e there was no release of 1.x with SerializerMutation. It was added in July and the most recent 1.x release was 1.3 in April.

For anyone who is interested I opened #261 to try to get SerializerMutation working again for 2.x

0reactions
abdulhaq-ecommented, Aug 30, 2017

There must’ve been something wrong with publishing. I didn’t experience it because I had a similar scenario as yours where I had a local copy of graphene-django in my app rather than the version on PyPy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: 'NoneType' object is not callable using restframework
I'm building a customer user using restframework, but I get this error: TypeError: 'NoneType' object is not callable.
Read more >
TypeError: 'NoneType' object is not callable : r/django - Reddit
The first error is that self. model is not defined, so you can't call it. Replace it with CustomUser or (better) the result...
Read more >
'NoneType' object is not callable (smart_unicode is None)
This seems to be some kind of magic import related bug, since there doesn't seem to be any natural way for the symbol...
Read more >
"TypeError: 'NoneType' object is not callable" when building ...
I've verified it in both Python 3.10.0 and 3.10.2 with files mapped to my project venv. My app makes a request to an...
Read more >
TypeError: 'NoneType' object is not callable in Python
The Python TypeError: 'NoneType' object is not callable occurs when we try to call a `None` value as if it were a function....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found