Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend schema crashes on unbound methods #43

Closed
delyanr opened this issue Jul 15, 2019 · 3 comments
Closed

Extend schema crashes on unbound methods #43

delyanr opened this issue Jul 15, 2019 · 3 comments

Comments

@delyanr
Copy link

delyanr commented Jul 15, 2019

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.

@Cito
Copy link
Member

Cito commented Jul 15, 2019

Right, that's a bug. Can you check whether the above fix solves the problem? I'll deploy a bugfix release then.

@delyanr
Copy link
Author

delyanr commented Jul 16, 2019

That seems to do it. Thanks for the quick one!

@Cito
Copy link
Member

Cito commented Jul 17, 2019

Thank you for the bug report. This is now fixed in core-next 1.1.1 and core 3.0.0a1.

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

No branches or pull requests

2 participants