Skip to content

Parsing incorrectly wipes out mapping #325

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

Closed
pvanderlinden opened this issue May 3, 2022 · 12 comments
Closed

Parsing incorrectly wipes out mapping #325

pvanderlinden opened this issue May 3, 2022 · 12 comments
Labels
type: bug An issue or pull request relating to a bug

Comments

@pvanderlinden
Copy link
Contributor

Describe the bug
The parsing logic completely wipes out parent value, if one of the fields in null.

e.g. the value is a list with a type in it with the following definition (removed all the other fields for simplicity)

  node {
    ...other fields
    from {
      address
    }
    to {
      address
    }
  }
}

if I get the following result:

[
{'node': {'from': {'address': '0x45b9ad45995577fe'}, 'to': {'address': '0x6394e988297f5ed2'}}},
{'node': {'from': None, 'to': {'address': '0x6394e988297f5ed2'}}},
]

the parsed result will end up being:

[
{'node': {'from': {'address': '0x45b9ad45995577fe'}, 'to': {'address': '0x6394e988297f5ed2'}}},
None
]

Expected behavior
Result should be:

[
{'node': {'from': {'address': '0x45b9ad45995577fe'}, 'to': {'address': '0x6394e988297f5ed2'}}},
{'node': {'from': None, 'to': {'address': '0x6394e988297f5ed2'}}},
]

System info (please complete the following information):

  • OS: Linux
  • Python version: 3.10
  • gql version: 3.2.0
  • graphql-core version: 3.2.1
@leszekhanusz
Copy link
Collaborator

It is not clear what you mean by "parsing logic".

Please help me to reproduce your problem:

  • which code did you use (sync or async, which transport, which arguments, ...) Please post your full code.
  • what is the backend?
  • please provide a schema and a full valid query and the expected response.

@leszekhanusz
Copy link
Collaborator

Please also activate debug logs and post the result here.

@pvanderlinden
Copy link
Contributor Author

I'm currently trying to write a test to demonstrate the issue.

I don't know how much of the details as I can share as this is an alpha version of a backend I have access to with authentication. I don't think the backend matters in anyway to be honest. This is purely when parsing the results (execute(parse_results=True). I have the debug logs, but again, not entirely sure what information I can post (and it will be a ton of logs).

@leszekhanusz
Copy link
Collaborator

ok, if you could make a failing test and add it as a PR that would be nice.

@pvanderlinden
Copy link
Contributor Author

@leszekhanusz

I created the failing test (without parse_results=True the test will pass). Is this clarifying the bug?

@pvanderlinden
Copy link
Contributor Author

This might be a bug in graphql-core, but I was unable to track down the cause of the bug so far.

@leszekhanusz leszekhanusz added the type: bug An issue or pull request relating to a bug label May 3, 2022
@Cito
Copy link
Member

Cito commented May 3, 2022

@pvanderlinden @leszekhanusz The problem seems to be somewhere in the parse_result_recursive function of gql (the ParseResultVisitor), not graphql-core.

@leszekhanusz
Copy link
Collaborator

Yes, it's possible I found the problem. I'll make more tests tomorrow and get the PR cleaned, I don't really remember why there was a special case for None here.

@pvanderlinden
Copy link
Contributor Author

Thanks. I will test run the branch tomorrow on my code

@leszekhanusz
Copy link
Collaborator

At least now I know there is at least one person using this feature 😄

@pvanderlinden
Copy link
Contributor Author

At least now I know there is at least one person using this feature 😄

Haha, always good to know. I'm using it to automatically convert 2 custom scalars: a datetime like type and a decimal (fixed point).

@leszekhanusz
Copy link
Collaborator

Fixed in v3.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug
Projects
None yet
Development

No branches or pull requests

3 participants