mutation {
createOrder(totalAmount: 40.5, orderType: "purchase") {
order {
totalAmount
orderType
id
}
}
}
on a model structure like (copied relevant parts only):
class Order(Document):
"""HT3 Order Model."""
meta = {'collection': 'order'}
order_type = StringField(choices=ORDER_TYPES, max_length=12, nullable=False)
total_amount = DecimalField(min_value=0)
class OrderSchema(MongoSchema):
"""Graphql representation of the Order Model."""
model = Order
@require_any_jwt_role(['admin', 'editor'])
def validator(model, fields, query, special_params):
"""Check if the current user can read this model. """
print('Order Graphql validator hook', file=sys.stderr)
class Mutation(ObjectType):
"""Graphql representation for saving project Models."""
create_order = OrderSchema.mutate
schema = Schema(query=Query, mutation=Mutation)
will respond with a:
{
"errors": [
{
"message": "Argument \"totalAmount\" has invalid value \"40.5\".\nExpected type \"CustomDecimalField\", found \"40.5\".",
"locations": [
{
"line": 2,
"column": 27
}
]
}
]
}
Tried with the amount as 40.5, "40.5" to no avail. Same error.
Your tests/examples are not using a DecimalField with a mutation anywhere... :(
Any ideas why a mutation like:
on a model structure like (copied relevant parts only):
will respond with a:
Tried with the amount as
40.5
,"40.5"
to no avail. Same error.Your tests/examples are not using a DecimalField with a mutation anywhere... :(
Thanks!