Skip to content

Commit b2d2bc2

Browse files
authored
Use a more performant GraphQL visibility plugin. (#466)
We've observed that the new `GraphQL::Schema::Visibility` plugin causes a large performance degradation. `GraphQL::Schema::Warden` does not have this issue, so until it's fixed we'll stick with it. ``` ruby 3.3.4 (2024-07-09 revision be1089c8ec) [arm64-darwin23] Warming up -------------------------------------- Using Visibility 10.000 i/100ms Using Warden 248.000 i/100ms Calculating ------------------------------------- Using Visibility 102.340 (± 2.0%) i/s (9.77 ms/i) - 520.000 in 5.082553s Using Warden 2.471k (± 4.9%) i/s (404.71 μs/i) - 12.400k in 5.030776s Comparison: Using Warden: 2470.9 i/s Using Visibility: 102.3 i/s - 24.14x slower ``` See rmosolgo/graphql-ruby#5324 for details on this issue.
1 parent 95e0f8d commit b2d2bc2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Diff for: elasticgraph-graphql/lib/elastic_graph/graphql.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,12 @@ def graphql_gem_plugins
135135
{
136136
# We depend on this to avoid N+1 calls to the datastore.
137137
::GraphQL::Dataloader => {},
138-
# This is new in the graphql-ruby 2.4 release, and will be required in the future.
139-
# We pass `preload: true` because the way we handle the schema depends on it being preloaded.
140-
::GraphQL::Schema::Visibility => {preload: true}
138+
# Here we opt-in to the old `GraphQL::Schema::Warden` visibility plugin.
139+
# The new plugin, `GraphQL::Schema::Visibility`, causes a performance regression
140+
# in ElasticGraph projects, and until that's fixed we want to stick with the old plugin.
141+
#
142+
# TODO: switch back to `::GraphQL::Schema::Visibility => {preload: true}` once the perf issue has been fixed.
143+
::GraphQL::Schema::Warden => {}
141144
}
142145
end
143146
end

Diff for: elasticgraph-graphql/sig/graphql_gem.rbs

+3
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ module GraphQL
173173
def self.print_schema: (Schema, **untyped) -> ::String
174174
end
175175

176+
class Warden
177+
end
178+
176179
class Visibility
177180
end
178181
end

0 commit comments

Comments
 (0)