graphene icon indicating copy to clipboard operation
graphene copied to clipboard

Field names in validation errors are different from schema

Open igo opened this issue 6 years ago • 7 comments

I have a form which has a python field raw_description which ends up in schema as rawDescription. However if field doesn't have a valid value I get a validation error for field raw_description which is not in schema.

class UpdateEventModelForm(forms.ModelForm):
    raw_description = forms.CharField()
    class Meta:
        model = EventModel
        fields = ('name', 'from_date', 'to_date')
mutation updateEvent($input: UpdateEventInput!) {
  updateEvent(input: $input) {
    errors {
      field
      messages
    }
  }
}

{
    "input": {
      "id": 123,
      "rawDescription": ""
    }
}

Response

{
  "data": {
    "updateEvent": {
      "errors": [
        {
          "field": "raw_description",
          "messages": [
            "This field is required."
          ]
        }
      ],
      "event": null
    }
  }
}

igo avatar Jan 27 '20 21:01 igo

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[bot] avatar Apr 26 '20 21:04 stale[bot]

Not stale

igo avatar Apr 27 '20 08:04 igo

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[bot] avatar Jul 26 '20 09:07 stale[bot]

Not stale

igo avatar Jul 26 '20 09:07 igo

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[bot] avatar Oct 25 '20 00:10 stale[bot]

Issue stale is not

-- Yoda

igo avatar Oct 26 '20 18:10 igo

@igo I'm assuming you're using graphene-django here? Have you tried the CAMELCASE_ERRORS setting? https://docs.graphene-python.org/projects/django/en/latest/settings/#camelcase-errors

jkimbo avatar Oct 27 '20 08:10 jkimbo