Skip to content

Extend schema crashes on unbound methods #43

Closed
@delyanr

Description

@delyanr

Hello,

Context: Windows 10, ariadne==0.5, graphql-core-next==1.1.0

Recently upgraded to the latest version of graphql-core-next, and I'm getting the following exception when using extend_schema:

  File "C:\Anaconda3\envs\structor\lib\site-packages\graphql\utilities\extend_schema.py", line 335, in extend_schema
    type_map[existing_type_name] = extend_named_type(existing_type)
  File "C:\Anaconda3\envs\structor\lib\site-packages\graphql\utilities\extend_schema.py", line 150, in extend_named_type
    return extend_scalar_type(type_)
  File "C:\Anaconda3\envs\structor\lib\site-packages\graphql\utilities\extend_schema.py", line 225, in extend_scalar_type
    kwargs = type_.to_kwargs()
  File "C:\Anaconda3\envs\structor\lib\site-packages\graphql\type\definition.py", line 397, in to_kwargs
    if getattr(self.parse_literal, "__func__")
AttributeError: 'function' object has no attribute '__func__'

This new version tries to get the __func__ attribute of the literal parser for a custom scalar, which assumes that the parser is a bound method. There are many libraries, incl. ariande, that attach such parsers (and resolvers) after the scalars have been initialised. Therefore, these newly attached methods are no longer bound. I see no reason for this constraint, so could you please fix?

Many thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions