input_object_type_definition.ex (1751B)
1 defmodule Absinthe.Blueprint.Schema.InputObjectTypeDefinition do 2 @moduledoc false 3 4 alias Absinthe.{Blueprint, Type} 5 6 @enforce_keys [:name] 7 defstruct [ 8 :identifier, 9 :name, 10 :module, 11 description: nil, 12 fields: [], 13 imports: [], 14 directives: [], 15 source_location: nil, 16 # Added by phases, 17 flags: %{}, 18 errors: [], 19 __reference__: nil, 20 __private__: [] 21 ] 22 23 @type t :: %__MODULE__{ 24 name: String.t(), 25 description: nil | String.t(), 26 fields: [Blueprint.Schema.InputValueDefinition.t()], 27 directives: [Blueprint.Directive.t()], 28 source_location: nil | Blueprint.SourceLocation.t(), 29 # Added by phases 30 flags: Blueprint.flags_t(), 31 errors: [Absinthe.Phase.Error.t()] 32 } 33 34 def build(type_def, schema) do 35 %Type.InputObject{ 36 identifier: type_def.identifier, 37 name: type_def.name, 38 fields: build_fields(type_def, schema), 39 description: type_def.description, 40 definition: type_def.module 41 } 42 end 43 44 def build_fields(type_def, schema) do 45 for field_def <- type_def.fields, into: %{} do 46 field = %Type.Field{ 47 identifier: field_def.identifier, 48 deprecation: field_def.deprecation, 49 description: field_def.description, 50 name: field_def.name, 51 type: Blueprint.TypeReference.to_type(field_def.type, schema), 52 definition: type_def.module, 53 __reference__: field_def.__reference__, 54 __private__: field_def.__private__, 55 default_value: field_def.default_value 56 } 57 58 {field.identifier, field} 59 end 60 end 61 62 defimpl Inspect do 63 defdelegate inspect(term, options), 64 to: Absinthe.Schema.Notation.SDL.Render 65 end 66 end