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

Upgrade GraphQL gem to 2.4.5 and deal with eager loading. #43

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion elasticgraph-apollo/elasticgraph-apollo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ElasticGraphGemspecHelper.define_elasticgraph_gem(gemspec_file: __FILE__, catego

spec.add_dependency "elasticgraph-graphql", eg_version
spec.add_dependency "elasticgraph-support", eg_version
spec.add_dependency "graphql", "~> 2.4.3"
spec.add_dependency "graphql", "~> 2.4.5"
spec.add_dependency "apollo-federation", "~> 3.8"

# Note: technically, this is not purely a development dependency, but since `eg-schema_def`
Expand Down
2 changes: 1 addition & 1 deletion elasticgraph-graphql/elasticgraph-graphql.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ElasticGraphGemspecHelper.define_elasticgraph_gem(gemspec_file: __FILE__, catego

spec.add_dependency "elasticgraph-datastore_core", eg_version
spec.add_dependency "elasticgraph-schema_artifacts", eg_version
spec.add_dependency "graphql", "~> 2.4.3"
spec.add_dependency "graphql", "~> 2.4.5"

spec.add_development_dependency "elasticgraph-admin", eg_version
spec.add_development_dependency "elasticgraph-elasticsearch", eg_version
Expand Down
3 changes: 3 additions & 0 deletions elasticgraph-graphql/lib/elastic_graph/graphql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ def monotonic_clock
# at boot time instead of deferring dependency loading until we handle the first query. In other environments (such as tests),
# it's nice to load dependencies when needed.
def load_dependencies_eagerly
require "graphql"
::GraphQL.eager_load!

# run a simple GraphQL query to force load any dependencies needed to handle GraphQL queries
graphql_query_executor.execute(EAGER_LOAD_QUERY, client: Client::ELASTICGRAPH_INTERNAL)
graphql_http_endpoint # force load this too.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# frozen_string_literal: true

require "graphql/dataloader/source"
require "graphql"

module ElasticGraph
class GraphQL
Expand Down
2 changes: 2 additions & 0 deletions elasticgraph-graphql/sig/graphql_gem.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module GraphQL
class CoercionError < StandardError
end

def self.eager_load!: () -> void

class Dataloader
class Source
def load_all: [Req, Res] (::Array[Req]) -> ::Array[Res]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

require "elastic_graph/graphql/query_details_tracker"
require "elastic_graph/graphql/resolvers/query_source"
require "graphql/dataloader"
require "graphql"

module ElasticGraph
class GraphQL
Expand Down
2 changes: 1 addition & 1 deletion elasticgraph-graphql/spec/support/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
require "elastic_graph/graphql/query_details_tracker"
require "elastic_graph/graphql/resolvers/query_adapter"
require "elastic_graph/graphql/resolvers/query_source"
require "graphql/dataloader"
require "graphql"

module ResolverHelperMethods
def resolve(type_name, field_name, document = nil, **options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ElasticGraphGemspecHelper.define_elasticgraph_gem(gemspec_file: __FILE__, catego

spec.add_dependency "elasticgraph-graphql", eg_version
spec.add_dependency "elasticgraph-support", eg_version
spec.add_dependency "graphql", "~> 2.4.3"
spec.add_dependency "graphql", "~> 2.4.5"
spec.add_dependency "rake", "~> 13.2"

spec.add_development_dependency "elasticgraph-elasticsearch", eg_version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

require "elastic_graph/graphql/query_executor"
require "elastic_graph/query_registry/registry"
require "graphql/query/result"
require "graphql"
require "pathname"

module ElasticGraph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ElasticGraphGemspecHelper.define_elasticgraph_gem(gemspec_file: __FILE__, catego
spec.add_dependency "elasticgraph-json_schema", eg_version
spec.add_dependency "elasticgraph-schema_artifacts", eg_version
spec.add_dependency "elasticgraph-support", eg_version
spec.add_dependency "graphql", "~> 2.4.3"
spec.add_dependency "graphql", "~> 2.4.5"
spec.add_dependency "rake", "~> 13.2"

spec.add_development_dependency "elasticgraph-admin", eg_version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
require "elastic_graph/schema_definition/rake_tasks"
require "elastic_graph/schema_definition/schema_elements/type_namer"
require "graphql"
require "graphql/language/block_string"
require "yaml"

module ElasticGraph
Expand Down
Loading