-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
There doesn't seem to be a way to override is_type_of on objects #25
Comments
HI @ezyang, thanks for reporting this issue.
However, I see that that graphql-core-next currently checks It would certainly be a good idea and very simple to extend graphql-core-next to check for So probably we should use the special name |
A special name like Note that it's not impossible to demangle it, if you really wanted to. But I think it's probably better here to just hew to Pythonic conventions. |
I also considered demangling and immediately dismissed the idea. But now after sleeping over it, I am thinking maybe it is not so bad an idea after all. The rule for the mangling - prefixing with the class name- is well documened and not implementation specific, and the class name can be easily inspected. That would allow us to be completely compatible to GraphQL.js and consistent between dicts and class based objects. Another option would be check both attributes ( |
So I decided to go with the demangling. This will be available in the next version (released soon). Please reopen if you have any better ideas. |
Version 1.0,2 with this fix has now been released on PyPI. |
Hi @Cito , we might need to reopen this! class Node:
@property
def __typename(self):
return self.__class__.__name__
class A(Node):
.... Obviously Something like this (instead of just using a simple def get_typename(value):
for cls in value.__class__.__mro__:
__typename = getattr(value, f"_{cls.__name__}__typename", None)
if __typename:
return __typename
return None What do you think? |
Good point @Hellzed. Will add your |
This is implemented now in the master branch and will be available in the next beta release. |
Version 3.1.0b1 with this fix has been released now. |
In my server, I have the following lines: https://github.com/ezyang/ghstack/blob/973ef7b25a71afa8f813cd8107f227938b3413f1/ghstack/github_fake.py#L288
I don't know how to put these on the Repository/PullRequest classes, in the same way resolvers can be put on the appropriate object class and then automatically called. The obvious things (e.g., adding an
is_type_of
method) do not work.The text was updated successfully, but these errors were encountered: