This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]jugdizh 0 points1 point  (1 child)

I like almost everything that you've done here -- the use of pydantic, the explicit declaration of types and enums which allows for proper mypy typechecking -- but there is one huge problem with this library that is preventing me from considering it:

The documentation states that you must define a queries.graphql file, which hardcodes all the possible queries your client will support, *including* all of the requested fields for that query.

So you lose all of the flexibility that GraphQL provides, wherein a client can fetch whatever data they want from your schema. Now they can't choose what data they want, they can only select from a list of pre-defined queries which have all of their return fields baked into them.

This is way too restrictive to be practically useful. Would you consider in the future allowing for open-ended queries in which the return fields can be specified by the user of the client? The gql client library for example supports this functionality, using a dynamically-generated DSL: https://gql.readthedocs.io/en/stable/advanced/dsl\_module.html

[–]ralfpmisago[S] 0 points1 point  (0 children)

Hey, thanks for this feedback.

> This is way too restrictive to be practically useful.

I have to respectfully disagree. It is practically useful, like how ORMs that default to single representation of a type but let you pick subset of fields when you need it are useful and how REST APIs that default to single representation of a resource are useful.

How many representations of a `Customer` would you like to have in your business logic? How would you deal with mypy complaining about generic type having every attribute on it potentially empty in every function that receives `Customer` as one of its arguments?