profusion / sgqlc

Simple GraphQL Client
https://sgqlc.readthedocs.io/
ISC License
513 stars 85 forks source link

Codegen/schema.py: KeyError is thrown if a passed arg to write_arg doesn't have a defaultValue key #146

Closed hofmatthias closed 3 years ago

hofmatthias commented 3 years ago

If a passed arg in write_arg in schema.py doesn't have a defaultValue this throws a KeyError:

Currently: defval = arg['defaultValue'] if defval: ...

Proposal: defval = arg['defaultValue'] if "defaultValue" in arg.keys() else None

barbieri commented 3 years ago

I'll take a look, likely it's better to just defval = arg.get('defaultValue') but I'll see.

I think I didn't notice this one since most servers return that property even when it has no value

hofmatthias commented 3 years ago

I had that issue with the schema I retrieved from the company I work at right now. I can fix it locally, but it's better to have it available on master.

barbieri commented 3 years ago

released as https://pypi.org/project/sgqlc/13.0/