mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 06:14:46 +01:00
* Add gql client generation files * Update dependencies * Add stash-box client generation to the makefile * Move scraped scene object matchers to models * Add stash-box to scrape with dropdown * Add scrape scene from fingerprint in UI
50 lines
1.6 KiB
Text
50 lines
1.6 KiB
Text
{{- range $input := .Inputs }}
|
|
{{- if not .HasUnmarshal }}
|
|
func (ec *executionContext) unmarshalInput{{ .Name }}(ctx context.Context, obj interface{}) ({{.Type | ref}}, error) {
|
|
var it {{.Type | ref}}
|
|
var asMap = obj.(map[string]interface{})
|
|
{{ range $field := .Fields}}
|
|
{{- if $field.Default}}
|
|
if _, present := asMap[{{$field.Name|quote}}] ; !present {
|
|
asMap[{{$field.Name|quote}}] = {{ $field.Default | dump }}
|
|
}
|
|
{{- end}}
|
|
{{- end }}
|
|
|
|
for k, v := range asMap {
|
|
switch k {
|
|
{{- range $field := .Fields }}
|
|
case {{$field.Name|quote}}:
|
|
var err error
|
|
|
|
ctx := graphql.WithFieldInputContext(ctx, graphql.NewFieldInputWithField({{$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, err
|
|
}
|
|
if data, ok := tmp.({{ $field.TypeReference.GO | ref }}) ; ok {
|
|
it.{{$field.GoFieldName}} = data
|
|
{{- if $field.TypeReference.IsNilable }}
|
|
} else if tmp == nil {
|
|
it.{{$field.GoFieldName}} = nil
|
|
{{- end }}
|
|
} else {
|
|
return it, fmt.Errorf(`unexpected type %T from directive, should be {{ $field.TypeReference.GO }}`, tmp)
|
|
}
|
|
{{- else }}
|
|
it.{{$field.GoFieldName}}, err = ec.{{ $field.TypeReference.UnmarshalFunc }}(ctx, v)
|
|
if err != nil {
|
|
return it, err
|
|
}
|
|
{{- end }}
|
|
{{- end }}
|
|
}
|
|
}
|
|
|
|
return it, nil
|
|
}
|
|
{{- end }}
|
|
{{ end }}
|