Skip to content

Deprecate QueryOptions and MutationOptions #207

Closed
@Archmonger

Description

@Archmonger

Ref: #113

Current Situation

use_query and use_mutation currently require QueryOptions and MutationOptions objects to configure their behavior. Adding an extra import just for configuration is pretty annoying.

Proposed Actions

Deprecate QueryOptions and MutationOptions in favor of a different interface.

def use_query(
    query: Callable[FuncParams, Awaitable[Inferred]] | Callable[FuncParams, Inferred],
    args: Sequence | None = None,
    kwargs: MutableMapping | None = None,
    /,
    postprocessor: AsyncPostprocessor | SyncPostprocessor | None = None,
    postprocessor_kwargs: MutableMapping | None = None,
    thread_sensitive: bool = True,
):
    ...

This interface does pose a new challenge. Type hints for args and kwargs will no longer receive auto-complete support due to Python type hint limitations. However, this seems to be worth the trade off. Especially since it's likely this type hint limitation will eventually get resolved.

An alternative is to use unpacking (for example use_query(... , *args, **kwargs)), however, this would result in our configuration options, such as thread_sensitive and postprocessor, stepping into the bounds of **kwargs. As a result, that is unfortunately not a good solution since every config option we add has the potential to break a user application.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions