You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there! Thanks for creating these helpers. Delightful code to work with. I hope I'm just missing something, but it seems like the last version bump broke support for snake case field testing.
When testing a snake case field name, version 1.2 of this gem assumes the field name to be camelized and camelizes the expected field name even though the field on the schema is snake case.
I'm using 1.8.4 of the graphql gem and 1.2 of the rspec-graphql_matchers gem, for context
Type definition:
class ExampleType < GraphQL::Schema::Object
# metadata
field :existing_snake_case_field, String, null: true, camelize: false
def resolve
# logic and things
end
end
RSpec Expectation:
require "rails_helper"
require "rspec/graphql_matchers"
RSpec.describe Types::Objects::ExampleType do
subject { described_class }
it { is_expected.to have_field(:existing_snake_case_field).of_type "String" }
end
Error I'm seeing:
Failure/Error: it { is_expected.to have_field(:existing_snake_case_field).of_type "String" }
expected Example to define field `existingSnakeCaseField` but no field was found with that name
If I dig a little further, I see that the fields hash on the type I'm testing has a snake_case field name key, rather than the camelCase version. The matcher seems to assume that the field key will be camelCase and compares the camelCase @expected_field_name to the snake case hash key, getting nil back, and subsequently failing.
I would just bump the version back to v1.1 but that drops support for snake_case arguments which are also inherent in our code base. Seems like we have to leave one or the other untested, which is... not ideal. Again, I hope I'm just missing something. Thanks!
The text was updated successfully, but these errors were encountered:
Hi there! Thanks for creating these helpers. Delightful code to work with. I hope I'm just missing something, but it seems like the last version bump broke support for snake case field testing.
When testing a snake case field name, version 1.2 of this gem assumes the field name to be camelized and camelizes the expected field name even though the field on the schema is snake case.
I'm using
1.8.4
of thegraphql
gem and1.2
of therspec-graphql_matchers
gem, for contextType definition:
RSpec Expectation:
Error I'm seeing:
If I dig a little further, I see that the fields hash on the type I'm testing has a snake_case field name key, rather than the camelCase version. The matcher seems to assume that the field key will be camelCase and compares the camelCase @expected_field_name to the snake case hash key, getting nil back, and subsequently failing.
It seems to be related to this change, which added support for snake case arguments, but assumes the camelization of the field name: https://github.com/khamusa/rspec-graphql_matchers/pull/29/files#diff-4820620b0dee82dd3ac38023e704859eR13
I would just bump the version back to v1.1 but that drops support for snake_case arguments which are also inherent in our code base. Seems like we have to leave one or the other untested, which is... not ideal. Again, I hope I'm just missing something. Thanks!
The text was updated successfully, but these errors were encountered: