Do not interpret Enum members called 'description' as description properties#1478
Conversation
Codecov ReportBase: 95.94% // Head: 95.95% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #1478 +/- ##
==========================================
+ Coverage 95.94% 95.95% +0.01%
==========================================
Files 50 50
Lines 1726 1731 +5
==========================================
+ Hits 1656 1661 +5
Misses 70 70
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
a8eccee to
1754dd1
Compare
…perties This is a workaround for `TypeError`s being raised when initialising schemas with Enum members named `description` or `deprecation_reason`. It is still not ideal as you can't have an enum with both a "description" member and a description property. Fixing this would require some more thought though. Potentially we could allow something like `__description__` as an alternative way of naming the description property in cases where it conflicts with one of the members. Fixes graphql-python#1321
1754dd1 to
1e12800
Compare
|
This might help users that need to define an enum member called description in their schema. |
Yeah, we are hitting this issue in one of our graphQL APIs. It auto-generates a schema at initialisation time from the database schema, which has elements named "description". I've worked around it for now by registering |
|
Maybe we can include a The significant disadvantage of all |
|
I can't think of an elegant solution that keeps descriptions working the way they currently do while also allowing for Enum members called "description" to have descriptions. This PR is a fairly conservative change in that it shouldn't break any existing functionality, but fixes the case where there is an Enum with a member called "description" that doesn't have a description. |
|
Took some time to play around with alternatives, and I agree that this is the only non breaking solution we have without reworking enums while changing as little as possible. Thanks for PRing this! |
Thanks for the review and for helping to maintain graphene. It's much appreciated! |
|
Hello @mike-roberts-healx, Nice fix I was struggling with it some hours ago, is it already available for version 3.1.1? I've already installed it, but I just can't get your change |
|
@julianmoji Ill release a patch soon, for now you can also install this PR in pip/poetry as a workaround:) |
|
This is now released in 3.2.0: https://github.com/graphql-python/graphene/releases/tag/v3.2.0 |
|
@erikwrede Thanks you so much man :) |
This is a workaround for
TypeErrors being raised when initialising schemas with Enum members nameddescriptionordeprecation_reason.It is still not ideal as you can't have an enum with both a "description" member and a description property. Fixing this would require some more thought though. Potentially we could allow something like
__description__as an alternative way of naming the description property in cases where it conflicts with one of the members.Fixes #1321 (ish)