Class: ElasticGraph::GraphQLLambda::LambdaFunction

Inherits:
Object
  • Object
show all
Includes:
LambdaSupport::LambdaFunction
Defined in:
lib/elastic_graph/graphql_lambda/lambda_function.rb

Instance Method Summary collapse

Constructor Details

#initializeLambdaFunction

Returns a new instance of LambdaFunction.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/elastic_graph/graphql_lambda/lambda_function.rb', line 17

def initialize
  require "elastic_graph/graphql_lambda"
  require "elastic_graph/graphql_lambda/graphql_endpoint"

  graphql = ElasticGraph::GraphQLLambda.graphql_from_env

  # ElasticGraph loads things lazily by default. We want to eagerly load
  # the graphql gem, the GraphQL schema, etc. rather than waiting for the
  # first request, since we want consistent response times.
  graphql.load_dependencies_eagerly

  @graphql_endpoint = ElasticGraph::GraphQLLambda::GraphQLEndpoint.new(graphql)
end

Instance Method Details

#handle_request(event:, context:) ⇒ Object



31
32
33
# File 'lib/elastic_graph/graphql_lambda/lambda_function.rb', line 31

def handle_request(event:, context:)
  @graphql_endpoint.handle_request(event: event, context: context)
end