def get_field_args(field):
types = {
str: graphene.String,
bool: graphene.Boolean,
int: graphene.Int,
float: graphene.Float,
}
try:
args = inspect.signature(field)
result = {}
for name, arg in args.parameters.items():
if arg.default is not None:
custom_type = types[type(arg.default)]
else:
custom_type = graphene.String
result.update({name: custom_type()})
return result
except (KeyError, ValueError):
return {}
评论列表
文章目录