aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/vektah/gqlgen/codegen/templates/interface.gotpl
blob: 817d0abe5408c488838bb4c09278b731dd820fd2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{{- $interface := . }}

func (ec *executionContext) _{{$interface.GQLType}}(ctx context.Context, sel []query.Selection, obj *{{$interface.FullName}}) graphql.Marshaler {
	switch obj := (*obj).(type) {
	case nil:
		return graphql.Null
	{{- range $implementor := $interface.Implementors }}
		{{- if $implementor.ValueReceiver }}
			case {{$implementor.FullName}}:
				return ec._{{$implementor.GQLType}}(ctx, sel, &obj)
		{{- end}}
		case *{{$implementor.FullName}}:
			return ec._{{$implementor.GQLType}}(ctx, sel, obj)
	{{- end }}
	default:
		panic(fmt.Errorf("unexpected type %T", obj))
	}
}