Conversation
As outlined in rmosolgo#2611 there appears to be a bug in argument deserialization if the argument contains a number. This bug was confirmed by @rmosolgo [here](rmosolgo#2611 (comment)) This commit contains a patch for the bug. The culprit was `GraphQL::Schema::Member::BuildType#underscore`. Upon investigation, this method used gsub` to include underscores but just split the string based on letters. This was confirmed by adding a test for the `#underscore` method in `spec/graphql/schema/member/build_type_spec.rb` which was not initially present. After identifying the issue, the following two `gsub` calls were chained to the `underscore` method: ```ruby .gsub(/([A-Za-z]+)([0-9]+)/,'\1_\2') # some1 -> some_1 .gsub(/([0-9]+)([A-Za-z]+)/,'\1_\2') # 1thing -> 1_thing ``` Having added the tests that confirm the bug has been fixed, a number of other tests failed due to the test code using the incorrectly deserialized values. This commit also patches these tests.
|
@rmosolgo, if this PR is fit for purpose, would you rather the extra files be submitted as patches in a set of other commits so that this commit just deals with the bug itself (I mean submitting the changes to |
|
Sorry for the slow response here. I'm a little bit wary of this change because it looks like it will change behavior for anyone using names like Do you think it's possible to respect the case as written in the field name? That is, if someone writes |
Yeah, that is the case which is why I'm not too keen on it either.
That's something that I'll have to look into. Any pointers on where to start looking for that? |
I think it basically requires a paradigm shift on how this works. Currently, the library assumes that:
However, the issue you outlined over in #2611 demonstrates a flaw in this approach: we have differing expectations about how the transform should work -- or at least, the way it previously worked was wrong. So, I think a better approach to this feature would be:
In an approach like that, I'm not exactly sure what will be required to implement that, but I think you could basically start by:
But, I'm not exactly sure how that will play out 🙈 ! |
|
I took a different approach in #2792 which maintained the current behavior, too. Please give it a try on master or 1.10.4 which will be released soon, and let me know if you run into any trouble! |
As outlined in #2611
there appears to be a bug in argument deserialization if the argument
contains a number. This bug was confirmed by @rmosolgo here
This commit contains a patch for the bug. The culprit was
GraphQL::Schema::Member::BuildType#underscore. Upon investigation,this method used
gsubto include underscores but just split the stringbased on letters. This was confirmed by adding a test for the
#underscoremethod inspec/graphql/schema/member/build_type_spec.rbwhich was not initially present.
After identifying the issue, the following two
gsubcalls were chainedto the
underscoremethod:Having added the tests that confirm the bug has been fixed, a number of
other tests failed due to the test code using the incorrectly
deserialized values. This commit also patches these tests.