graphql-python / gql

A GraphQL client in Python

Home Page:https://gql.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ability to deserialize to `NamedTuple` instead of `dict`

JLLeitschuh opened this issue · comments

NamedTuple has some benefits, including being immutable, meaning that they have predictable hash code, and can be used in sets.

This could be expanded to supporting custom deserializers into domain-specific objects. For example, if you would like to be able to customize the deserialization of a response into a custom object.

Sorry, I won't do this.

  • It would be a breaking change
  • If we add this as an option, it will complicate type hints for no good reason
  • If someone wants this, he can himself convert it to a NamedTuple from the Dict, with better performance as this can be applied only when needed
  • the best code is no code at all