kensho-technologies / graphql-compiler

Turn complex GraphQL queries into optimized database queries.
Apache License 2.0
550 stars 50 forks source link

Add better type hint for the output query type when compiling to a SQL backend #977

Open obi1kenobi opened 3 years ago

obi1kenobi commented 3 years ago

Currently, CompilationResult is an untyped namedtuple, which means that it's unclear what is the type of its query attribute. For non-SQL backends, it appears to be str, but for SQL it seems to be some SQLAlchemy-specific type and it's not clear which of its superclasses/protocols we should claim as the return type.

This is also a concern for the insert_arguments_into_query function, whose return type is the same type as CompilationResult.query and currently set to the correct-but-extremely-imprecise Any.