Skip to content

Conversation

hoefling
Copy link
Contributor

@hoefling hoefling commented May 1, 2020

It's me again with a type hints issue. I'm writing a custom field resolver:

def custom_field_resolver(source: Any, info: GraphQLResolveInfo, **args: Any) -> Any:
    if info.field_name == "foo" and hasattr(source, "bar"):
        return source.bar
    return default_field_resolver(source, info, **args)


result = await graphql_execute(
    ...,
    field_resolver=custom_field_resolver,
)

and have disallow_untyped_calls = True in my mypy config. Running the type check yields

<mymod>.py:<line>: error: Call to untyped function "default_field_resolver" in typed context

I'd thus propose to add at least a rudimentary typing to graphql.execute.default_field_resolver for now. Once Python 3.6 and 3.7 are dropped, I suppose a better typing using protocols could be possible.

Signed-off-by: oleg.hoefling [email protected]

@hoefling hoefling requested a review from Cito as a code owner May 1, 2020 10:14
@Cito
Copy link
Member

Cito commented May 4, 2020

LGTM, thank you. I have created #89 to solve this more radically in the long run.

@Cito Cito merged commit b70dc63 into graphql-python:master May 4, 2020
Cito added a commit that referenced this pull request May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants