You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the current behavior?
I have double nested inputs, the first two levels are properly converted to snake_case, the third one (deepest) is not.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via
a github repo, https://repl.it or similar.
importgraphenefromdjango.contrib.authimportget_user_modelfrom ..modelsimportPlace, PostalAddressUser=get_user_model()
classOwnerInput(graphene.InputObjectType):
first_name=graphene.String(required=True)
last_name=graphene.String(required=True)
classPostalAddressInput(graphene.InputObjectType):
street_address=graphene.String(required=True)
address_locality=graphene.String(required=True)
address_region=graphene.String(required=True)
postal_code=graphene.String(required=True)
address_country=graphene.String(required=True)
classPlaceInput(graphene.InputObjectType):
latitude=graphene.Float(required=True)
longitude=graphene.Float(required=True)
postal_address=graphene.Field(PostalAddressInput, required=True)
classRegisterPlaceInput(graphene.InputObjectType):
owner=graphene.Field(OwnerInput, required=True)
place=graphene.Field(PlaceInput, required=True)
classRegisterPlaceMutation(graphene.Mutation):
classArguments:
input=graphene.Argument(RegisterPlaceInput, required=True)
success=graphene.Boolean(
description="Indicates whether the operation was successful."
)
defmutate(root, info, input):
print(input)
owner_data=input['owner'] #Converted to snakeplace_data=input['place'] #converted to snake at the lower levelpostal_address_data=place_data['postal_address'] # remains camelpostal_address=PostalAddress.objects.create(**postal_address_data) #fails as data not in the right shapeplace=Place.objects.create(
latitude=place_data['latitude'],
longitude=place_data['longitude'],
postal_address=postal_address,
)
returnRegisterPlaceMutation(success=True)
classMutation(graphene.ObjectType):
register_place=RegisterPlaceMutation.Field()
What is the current behavior?
I have double nested inputs, the first two levels are properly converted to snake_case, the third one (deepest) is not.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via
a github repo, https://repl.it or similar.
print gives :
What is the expected behavior?
All nested object keys are converted to snake_case.
What is the motivation / use case for changing the behavior?
snake_case conversion should be consistent independently of the shape of the input
Please tell us about your environment:
The text was updated successfully, but these errors were encountered: