Skip to content

Conversation

helpse
Copy link

@helpse helpse commented Oct 15, 2018

No description provided.

@zbyte64
Copy link
Collaborator

zbyte64 commented Oct 15, 2018

Looks like django-filter < 2 does not have is_valid for filtersets and is used for python 2.7 ; it does however define a form property which django-filter > 2 also uses to look up errors.

@helpse
Copy link
Author

helpse commented Oct 30, 2018

@zbyte64 thanks! It's fixed now.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.1%) to 93.398% when pulling 016321c on inspired-solutions:fix/filterset-errors into f76f38e on graphql-python:master.

6 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-1.1%) to 93.398% when pulling 016321c on inspired-solutions:fix/filterset-errors into f76f38e on graphql-python:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.1%) to 93.398% when pulling 016321c on inspired-solutions:fix/filterset-errors into f76f38e on graphql-python:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.1%) to 93.398% when pulling 016321c on inspired-solutions:fix/filterset-errors into f76f38e on graphql-python:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.1%) to 93.398% when pulling 016321c on inspired-solutions:fix/filterset-errors into f76f38e on graphql-python:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.1%) to 93.398% when pulling 016321c on inspired-solutions:fix/filterset-errors into f76f38e on graphql-python:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.1%) to 93.398% when pulling 016321c on inspired-solutions:fix/filterset-errors into f76f38e on graphql-python:master.

@coveralls
Copy link

coveralls commented Oct 30, 2018

Coverage Status

Coverage increased (+0.02%) to 94.542% when pulling a855222 on inspired-solutions:fix/filterset-errors into f76f38e on graphql-python:master.

@helpse
Copy link
Author

helpse commented Nov 21, 2018

@zbyte64 want to review it?

for key, error_list in filterset.form.errors.as_data().items()
}

raise GraphQLError(exc)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're passing a dictionary here, but GraphQLError appears to take a str. Should we format this into a string? I'm not sure that relying on the stringifying behaviour of GraphQLError is the right thing to do.

One alternative would be to wrap up the dict -> str processing in a GraphQLDjangoFilterError (better name needed). This would:

a) make the code here simpler
b) make it easier to customise the behaviour in the view the API that lets the Django view intercept errors.


if not (filterset.is_bound and filterset.form.is_valid()):
exc = {
str(key): [str(e.message) for e in error_list]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key here is in Python/Django source casing I believe. I think we could improve the error reporting here anyway (see other comment), but if we do want to send these to the client, they should use the field names as in the API – i.e. probably camelCase names, although I believe this can be configured per schema, and overridden per field.

@stale
Copy link

stale bot commented Jun 11, 2019

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 11, 2019
@stale stale bot closed this Jun 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants