Skip to content
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

a field named "items" in InputObjectType occurs TypeError #1150

Open
jiyeonseo opened this issue Mar 8, 2020 · 2 comments
Open

a field named "items" in InputObjectType occurs TypeError #1150

jiyeonseo opened this issue Mar 8, 2020 · 2 comments
Labels

Comments

@jiyeonseo
Copy link

jiyeonseo commented Mar 8, 2020

I was trying to json.dumps with all inputs and some inputs had TypeError when they have a field named "items" like below.

class ConfigInput(graphene.InputObjectType):	    
    items = graphene.List(lambda: AnotherConfigInput)
    ...

when I try to json.dumps with this input, the error looks like

File "/project/venv/lib/python3.7/site-packages/playhouse/mysql_ext.py", line 36, in db_value
    return json.dumps(value)
  File "/Users/user/.pyenv/versions/3.7.4/lib/python3.7/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/Users/user/.pyenv/versions/3.7.4/lib/python3.7/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/Users/user/.pyenv/versions/3.7.4/lib/python3.7/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
TypeError: attribute of type 'list' is not callable

found that setattr in InputObjectType class overrides field's attr items which conflicts with the attribute items of List.

This is naming conflict, so I just solved it like below

class ConfigInput(graphene.InputObjectType):
    _items = graphene.List(lambda: AnotherConfigInput, name='items')
    ...

wonder if there is any good fix from graphene like this issue

please let me know if you need more info or examples :)

@stale
Copy link

stale bot commented Jun 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 6, 2020
@jkimbo jkimbo added the 🐛 bug label Jun 6, 2020
@stale stale bot removed the wontfix label Jun 6, 2020
@jkimbo
Copy link
Member

jkimbo commented Jun 6, 2020

Hmm that isn't very good! We shouldn't be overriding in built class methods. I'm going to mark this as a bug but I don't have much time to work on it at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants