Skip to content

Add a helpful message to when a global_id fails to parse. #1074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 10, 2020

Conversation

allen-munsch
Copy link
Contributor

@allen-munsch allen-munsch commented Sep 26, 2019

It was really difficult to determine that I wasn't using the correct format for an ID.

It was previously returning null, it now returns an error.message with Incorrect Padding and displays the exception traceback inside the server logs.

I'm not sure about whether return None is/was intended functionality.

I do see some of the tests are failing:

_________________________ test_node_query_incorrect_id _________________________
    def test_node_query_incorrect_id():
        executed = schema.execute(
            '{ node(id:"%s") { ... on MyNode { name } } }' % "something:2"
        )
>       assert not executed.errors

E       assert not [GraphQLError("Unable call from_global_id, is the id base64 encoding of 'TypeName:id': something:2 Exception: Incorrect padding", 
locations=[SourceLocation(line=1, column=3)], path=['node'])]

E        +  where [GraphQLError("Unable call from_global_id, is the id base64 encoding of 'TypeName:id': something:2 Exception: Incorrect padding", 
locations=[SourceLocation(line=1, column=3)], path=['node'])] = 
ExecutionResult(data={'node': None}, 
errors=[GraphQLError("Unable call from_global_id, is the id base64 encoding of 'TypeName:id': something:2 Exception: Incorrect padding", 
locations=[SourceLocation(line=1, column=3)], 
path=['node'])]).errors

edit: test updated.

@kazamatzuri
Copy link

@jkimbo
Copy link
Member

jkimbo commented Feb 8, 2020

@allen-munsch thanks for the contribution. I think this is a great addition and I've updated your PR and expanded the checks to cover more error cases.

@ekampf ekampf merged commit 23bb52a into graphql-python:master Feb 10, 2020
DoctorJohn added a commit to DoctorJohn/graphene-mongo that referenced this pull request Oct 11, 2020
DoctorJohn added a commit to DoctorJohn/graphene-mongo that referenced this pull request Jan 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants