DjangoModelFormMutation receive uncoded ID
See original GitHub issueHi everyone As already we know, queries with relay interface gives ID fields as base64; but form based mutations receive ID as natural string. Can we change to receive ID’s as base64 like relay?
class Genre(models.Model):
name = models.CharField(max_length=200)
def __str__(self):
return self.name
class GenreForm(forms.ModelForm):
class Meta:
model = Genre
fields = ['name']
class GenreNode(DjangoObjectType):
class Meta:
model = Genre
filter_fields = ['name']
interfaces = (relay.Node, )
class Queries(ObjectType):
genres = DjangoFilterConnectionField(GenreNode)
genre = relay.Node.Field(GenreNode)
class GenreMutation(DjangoModelFormMutation):
genre = Field(GenreNode)
class Meta:
form_class = GenreForm
class Mutations():
genre_mutation = GenreMutation.Field()
When you send the id as a relay id, you got this error:
"invalid literal for int() with base 10: 'Q2F0ZWdvcnlOb2RlOjEy'"
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Mutations - Graphene-Python
MyMutation will automatically receive an input argument. This argument should be a dict where the key is name and the value is a...
Read more >why flask graphene return wrong id? - Stack Overflow
when i print the id before returning, the code print the right value ( same with id in mongo ). but the client...
Read more >GraphQL + Django: DjangoModelFormMutation Walkthrough
AssertionError at /graphql You need to pass a valid Django Model in Query.Meta, received "None". I'm not entirely sure what causes this error, ......
Read more >How to use the graphene.ID function in graphene - Snyk
To help you get started, we've selected a few graphene.ID examples, based on popular ways it is used in public projects.
Read more >How to get Django Graphene ModelForm Mutation to apply
ID (required=True) class Meta: model = SubjectMark class AddSubjectMarkMutation(DjangoModelFormMutation): subject_mark = graphene.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Regarding the issue @javialon26 - in your example you’ve created a plain
DjangoModelFormMutation
which doesn’t know anything about relay. Adding a custom field to yourGenreForm
class to parse the ID as a relay ID would probably solve your issue.@ulgens the stalebot is useful to clean up old issues where the issue is no longer relevant but it can be overzealous and I haven’t been very good at keeping on top of issues. I’ll bump the days it takes to mark an issue as stale (to 120) and I’ll try and keep on top of issues as best I can. Any help with that would be most appreciated!