Skip to content

Commit 89eafc9

Browse files
authored
Merge pull request #5585 from rmosolgo/cache-type-wrapper-results
Cache `unwrap` and `to_type_signature` on type wrappers
2 parents 9b17bfa + e350409 commit 89eafc9

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

lib/graphql/schema/list.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def list?
1919
end
2020

2121
def to_type_signature
22-
"[#{@of_type.to_type_signature}]"
22+
@type_signature ||= -"[#{@of_type.to_type_signature}]"
2323
end
2424

2525
# This is for introspection, where it's expected the name will be `null`

lib/graphql/schema/non_null.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def list?
2424
end
2525

2626
def to_type_signature
27-
"#{@of_type.to_type_signature}!"
27+
@type_signature ||= -"#{@of_type.to_type_signature}!"
2828
end
2929

3030
def inspect

lib/graphql/schema/wrapper.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ def initialize(of_type)
1313
end
1414

1515
def unwrap
16-
@of_type.unwrap
16+
@unwrapped ||= @of_type.unwrap
17+
end
18+
19+
def freeze
20+
unwrap
21+
to_type_signature
22+
super
1723
end
1824

1925
def ==(other)

0 commit comments

Comments
 (0)