-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ONI-132: Changing mutation code to handle autogeneration. #206
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comment.
core/schema.py
Outdated
if mutation_data.get('autogenerate_code', None): | ||
returned = cls.async_mutate(info.context.user if info.context and info.context.user else None, | ||
**mutation_data) | ||
|
||
if isinstance(returned, Dict): | ||
data.update(returned) | ||
error_messages = None | ||
else: | ||
error_messages = returned | ||
else: | ||
error_messages = cls.async_mutate( | ||
info.context.user if info.context and info.context.user else None, | ||
**mutation_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code can be expressed as:
if mutation_data.get('autogenerate_code', None): | |
returned = cls.async_mutate(info.context.user if info.context and info.context.user else None, | |
**mutation_data) | |
if isinstance(returned, Dict): | |
data.update(returned) | |
error_messages = None | |
else: | |
error_messages = returned | |
else: | |
error_messages = cls.async_mutate( | |
info.context.user if info.context and info.context.user else None, | |
**mutation_data) | |
messages = cls.async_mutate(info.context.user if info.context and info.context.user else None, **mutation_data) | |
if mutation_data.get('autogenerate_code', False) and isinstance(messages, Dict): | |
data.update(messages) | |
error_messages = None | |
else: | |
error_messages = messages |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Ticket:https://openimis.atlassian.net/browse/ONI-132
Changes: