Skip to content
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

Check if prepare argument is a symbol or string #1762

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

KaanOzkan
Copy link
Contributor

@KaanOzkan KaanOzkan commented Jan 15, 2024

Motivation

Leftover from the refactor https://github.com/Shopify/tapioca/pull/1714/files#diff-8b787801eb4d5ed2047d8b5d37043650443fae0500ae270f8d7ededeb311f27cL68. It causes TypeError's when the argument isn't a symbol or a string.

Implementation

Bring back the previous check, call to_sym to please Sorbet.

Tests

Added

@KaanOzkan KaanOzkan requested a review from a team as a code owner January 15, 2024 19:03
if constant.respond_to?(prepare)
constant.method(prepare)
constant.method(prepare.to_sym)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think method takes either?

irb(main):002:0> String.new.method(:length)
=> #<Method: String#length()>
irb(main):003:0> String.new.method("length")
=> #<Method: String#length()>

Copy link
Contributor

@andyw8 andyw8 Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, just saw your other comment about Sorbet. Should we fix that upstream?

https://rubyapi.org/3.3/o/object#method-i-method

Copy link
Contributor Author

@KaanOzkan KaanOzkan Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but Sorbet doesn't know that https://github.com/sorbet/sorbet/blob/5e26c5107bda611cfa2068b75a7d6927ca1e8141/rbi/core/kernel.rbi#L555. I can fix it later, it's not as urgent as this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KaanOzkan KaanOzkan merged commit 7b845d7 into main Jan 15, 2024
33 checks passed
@KaanOzkan KaanOzkan deleted the ko/fix_graphql_type_for branch January 15, 2024 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants