{{- range $input := .Inputs }}
	{{- if not .HasUnmarshal }}
	{{- $it := "it" }}
	{{- if .PointersInUmarshalInput }}
	  {{- $it = "&it" }}
	{{- end }}
	func (ec *executionContext) unmarshalInput{{ .Name }}(ctx context.Context, obj interface{}) ({{ if .PointersInUmarshalInput }}*{{ end }}{{.Type | ref}}, error) {
		{{- if $input.IsMap }}
			it := make(map[string]interface{}, len(obj.(map[string]interface{})))
		{{- else }}
			var it {{.Type | ref}}
		{{- end }}
		asMap := map[string]interface{}{}
		for k, v := range obj.(map[string]interface{}) {
			asMap[k] = v
		}
		{{ range $field := .Fields}}
			{{- if notNil "Default" $field }}
				if _, present := asMap[{{$field.Name|quote}}] ; !present {
					asMap[{{$field.Name|quote}}] = {{ $field.Default | dump }}
				}
			{{- end}}
		{{- end }}

		fieldsInOrder := [...]string{ {{ range .Fields }}{{ quote .Name }},{{ end }} }
		for _, k := range fieldsInOrder {
			v, ok := asMap[k]
			if !ok {
				continue
			}
			switch k {
			{{- range $field := .Fields }}
			case {{$field.Name|quote}}:
				{{- $lhs := (printf "it.%s" $field.GoFieldName) }}
				{{- if $input.IsMap }}
					{{- $lhs = (printf "it[%q]" $field.Name) }}
				{{- end }}
				ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField({{$field.Name|quote}}))
				{{- if $field.ImplDirectives }}
					directive0 := func(ctx context.Context) (interface{}, error) { return ec.{{ $field.TypeReference.UnmarshalFunc }}(ctx, v) }
					{{ template "implDirectives" $field }}
					tmp, err := directive{{$field.ImplDirectives|len}}(ctx)
					if err != nil {
						return {{$it}}, graphql.ErrorOnPath(ctx, err)
					}
					if data, ok := tmp.({{ $field.TypeReference.GO | ref }}) ; ok {
						{{- if $field.IsResolver }}
							if err = ec.resolvers.{{ $field.ShortInvocation }}; err != nil {
								return {{$it}}, err
							}
						{{- else }}
							{{- if $field.TypeReference.IsOmittable }}
								{{ $lhs }} = graphql.OmittableOf(data)
							{{- else }}
								{{ $lhs }} = data
							{{- end }}
						{{- end }}
					{{- if $field.TypeReference.IsNilable }}
						{{- if not $field.IsResolver }}
						} else if tmp == nil {
							{{- if $field.TypeReference.IsOmittable }}
								{{ $lhs }} = graphql.OmittableOf[{{ $field.TypeReference.GO | ref }}](nil)
							{{- else }}
								{{ $lhs }} = nil
							{{- end }}
						{{- end }}
					{{- end }}
					} else {
						err := fmt.Errorf(`unexpected type %T from directive, should be {{ $field.TypeReference.GO }}`, tmp)
						return {{$it}}, graphql.ErrorOnPath(ctx, err)
					}
				{{- else }}
					{{- if $field.IsResolver }}
						data, err := ec.{{ $field.TypeReference.UnmarshalFunc }}(ctx, v)
						if err != nil {
							return {{$it}}, err
						}
						if err = ec.resolvers.{{ $field.ShortInvocation }}; err != nil {
							return {{$it}}, err
						}
					{{- else }}
						data, err := ec.{{ $field.TypeReference.UnmarshalFunc }}(ctx, v)
						if err != nil {
							return {{$it}}, err
						}
						{{- if $field.TypeReference.IsOmittable }}
							{{ $lhs }} = graphql.OmittableOf(data)
						{{- else }}
							{{ $lhs }} = data
						{{- end }}
					{{- end }}
				{{- end }}
			{{- end }}
			}
		}

		return {{$it}}, nil
	}
	{{- end }}
{{ end }}
