Method: GraphQL::Schema#initialize

Defined in:
lib/graphql/schema.rb

#initialize(query:, mutation: nil, subscription: nil, max_depth: nil, max_complexity: nil, types: []) ⇒ Schema

Returns a new instance of Schema.

Parameters:

  • query (GraphQL::ObjectType)

    the query root for the schema

  • mutation (GraphQL::ObjectType) (defaults to: nil)

    the mutation root for the schema

  • subscription (GraphQL::ObjectType) (defaults to: nil)

    the subscription root for the schema

  • max_depth (Integer) (defaults to: nil)

    maximum query nesting (if it's greater, raise an error)

  • types (Array<GraphQL::BaseType>) (defaults to: [])

    additional types to include in this schema



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/graphql/schema.rb', line 37

def initialize(query:, mutation: nil, subscription: nil, max_depth: nil, max_complexity: nil, types: [])
  @query    = query
  @mutation = mutation
  @subscription = subscription
  @max_depth = max_depth
  @max_complexity = max_complexity
  @orphan_types = types
  @directives = DIRECTIVES.reduce({}) { |m, d| m[d.name] = d; m }
  @static_validator = GraphQL::StaticValidation::Validator.new(schema: self)
  @rescue_middleware = GraphQL::Schema::RescueMiddleware.new
  @middleware = [@rescue_middleware]
  @query_analyzers = []
  # Default to the built-in execution strategy:
  self.query_execution_strategy = GraphQL::Query::SerialExecution
  self.mutation_execution_strategy = GraphQL::Query::SerialExecution
  self.subscription_execution_strategy = GraphQL::Query::SerialExecution
end