Method: GraphQL::Schema.from_definition

Defined in:
lib/graphql/schema.rb

.from_definition(definition_or_path, default_resolve: nil, parser: GraphQL.default_parser, using: {}, base_types: {}) ⇒ Class

Create schema from an IDL schema or file containing an IDL definition.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/graphql/schema.rb', line 114

def from_definition(definition_or_path, default_resolve: nil, parser: GraphQL.default_parser, using: {}, base_types: {})
  # If the file ends in `.graphql` or `.graphqls`, treat it like a filepath
  if definition_or_path.end_with?(".graphql") || definition_or_path.end_with?(".graphqls")
    GraphQL::Schema::BuildFromDefinition.from_definition_path(
      self,
      definition_or_path,
      default_resolve: default_resolve,
      parser: parser,
      using: using,
      base_types: base_types,
    )
  else
    GraphQL::Schema::BuildFromDefinition.from_definition(
      self,
      definition_or_path,
      default_resolve: default_resolve,
      parser: parser,
      using: using,
      base_types: base_types,
    )
  end
end