This repo is of a django project that demonstrates and error when upgrading graphene from 1.1.3 to 1.2.0 all other dependencies are frozen.
The following error is returned when running graphql_schema or any other executions on the schema
AssertionError: Schema must contain unique named types but contains multiple types named "SellOrderNode".
This test report shows the error.
Uses polymorphic models polymorphic model and returns the items with unions
Hi, I had the issue and I was able to fix it with this commit.
It seems that the following lines in graphql-core don't correctly compare GrapheneGraphQLType types, due to no fault of graphql-core itself. To fix this and any other issues with GrapheneGraphQLTypes being equivalent, I simply added an __eq__ comparison method to GrapheneGraphQLType to only compare the internal graphene_type and not the instances themselves.
```
if type.name in map:
assert map[type.name] == type, (
'Schema must contain unique named types but contains multiple types named "{}".'
).format(type.name)
````
I'd be happy to submit a pull request if this is, in fact, the correct way to go about solving this issue, but I can't say for sure due to my lack of experience with this library, so if any experienced graphene users can weigh in here please let me know.
@hueypeard thanks for the input, I'm not particularly versed on the internals myself (should probably do that anyway). I await the graphene teams input as well.
@hueypeard I can confirm copying the bit from your your posted solution does allow me to dump the schema.
So graphene-django requires 'graphene>=1.1.3' for one atm. When implementing the __eq__ method querying graphql returns
{
"errors": [
{
"message": "unhashable type: 'GrapheneObjectType'"
}
],
"data": {
"parts": null
}
}
Also the main motivation for upgrading is I need the lazy import feature
Revising this now. Thanks for the report :)
This is now fixed in master :).
I improved the TypeMap converter rather than modifying the __eq__ in the GrapheneGraphQLType as it's more robust and fixes the issue directly rather than silence it.
@syrusakbary you're amazing, thank you so much! My unit tests are now passing!
Fortunately I came across this. Pinning to master works.
Most helpful comment
@syrusakbary you're amazing, thank you so much! My unit tests are now passing!