Skip to content

Commit

Permalink
Merge pull request #43 from block/myron/upgrade-graphql
Browse files Browse the repository at this point in the history
Upgrade GraphQL gem to 2.4.5 and deal with eager loading.
  • Loading branch information
myronmarston authored Dec 3, 2024
2 parents 85f6dc2 + 8f0b162 commit 0cfd479
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 9 deletions.
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

0 comments on commit 0cfd479

Please sign in to comment.