Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Conversion to snake_case fails on nested inputs

オープン
#1,537 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
graphql, python
領域
api, backend

調査の方向性

RegisterPlaceInput、PlaceInput、PostalAddressInput の再現から始め、ネストされた InputObjectType 値がどのように変換されるかを追跡します。最深レベルの camelCase 出力を再現し、その後リグレッションカバレッジを追加して、ネストされたすべてのキーが snake_case に変換されることを確認します。

索引モデルが issue の本文から書いたものです。

説明

🐛 bug
  • 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.

import graphene
from django.contrib.auth import get_user_model

from ..models import Place, PostalAddress

User = get_user_model()

class OwnerInput(graphene.InputObjectType):
    first_name = graphene.String(required=True)
    last_name = graphene.String(required=True)

class PostalAddressInput(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)


class PlaceInput(graphene.InputObjectType):
    latitude = graphene.Float(required=True)
    longitude = graphene.Float(required=True)
    postal_address = graphene.Field(PostalAddressInput, required=True)


class RegisterPlaceInput(graphene.InputObjectType):
    owner = graphene.Field(OwnerInput, required=True)
    place = graphene.Field(PlaceInput, required=True)

class RegisterPlaceMutation(graphene.Mutation):
    class Arguments:
        input = graphene.Argument(RegisterPlaceInput, required=True)

    success = graphene.Boolean(
        description="Indicates whether the operation was successful."
    )

    def mutate(root, info, input):
        print(input)
        owner_data = input['owner'] #Converted to snake
        place_data = input['place'] #converted to snake at the lower level
        postal_address_data = place_data['postal_address'] # remains camel

        postal_address = PostalAddress.objects.create(**postal_address_data) #fails as data not in the right shape

        place = Place.objects.create(
            latitude=place_data['latitude'],
            longitude=place_data['longitude'],
            postal_address=postal_address,
        )

        return RegisterPlaceMutation(success=True)


class Mutation(graphene.ObjectType):
    register_place = RegisterPlaceMutation.Field()

print gives :

>>  {'owner': {'first_name': 'JOHN', 'last_name
': 'DOE'}, 'place': {'latitude': 48.9230953, 'longitude': 2.0303184, 'postal_address': {'streetAddress': 'Skalitzer Strasse 99', 'addressLocality': 'Berlin', 'addressRegion': 'Berlin', 'post
alCode': '10997', 'addressCountry': 'DE'}}}
  • 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:

    • Version: 3.3
    • Platform: with graphene_django 3.2 - (unsure if it's relevant)
主要言語
Python
スター
8.2k
フォーク
822
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

graphql-python/graphene のほかの issue

graphql-python/graphene の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。