aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/99designs/gqlgen/codegen/directives.gotpl
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/99designs/gqlgen/codegen/directives.gotpl')
-rw-r--r--vendor/github.com/99designs/gqlgen/codegen/directives.gotpl137
1 files changed, 0 insertions, 137 deletions
diff --git a/vendor/github.com/99designs/gqlgen/codegen/directives.gotpl b/vendor/github.com/99designs/gqlgen/codegen/directives.gotpl
deleted file mode 100644
index 67a0783e..00000000
--- a/vendor/github.com/99designs/gqlgen/codegen/directives.gotpl
+++ /dev/null
@@ -1,137 +0,0 @@
-{{ define "implDirectives" }}{{ $in := .DirectiveObjName }}
- {{- range $i, $directive := .ImplDirectives -}}
- directive{{add $i 1}} := func(ctx context.Context) (interface{}, error) {
- {{- range $arg := $directive.Args }}
- {{- if notNil "Value" $arg }}
- {{ $arg.VarName }}, err := ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, {{ $arg.Value | dump }})
- if err != nil{
- return nil, err
- }
- {{- else if notNil "Default" $arg }}
- {{ $arg.VarName }}, err := ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, {{ $arg.Default | dump }})
- if err != nil{
- return nil, err
- }
- {{- end }}
- {{- end }}
- return ec.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs $in $i }})
- }
- {{- end -}}
-{{ end }}
-
-{{define "queryDirectives"}}
- for _, d := range obj.Directives {
- switch d.Name {
- {{- range $directive := . }}
- case "{{$directive.Name}}":
- {{- if $directive.Args }}
- rawArgs := d.ArgumentMap(ec.Variables)
- args, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)
- if err != nil {
- ec.Error(ctx, err)
- return graphql.Null
- }
- {{- end }}
- n := next
- next = func(ctx context.Context) (interface{}, error) {
- return ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})
- }
- {{- end }}
- }
- }
- tmp, err := next(ctx)
- if err != nil {
- ec.Error(ctx, err)
- return graphql.Null
- }
- if data, ok := tmp.(graphql.Marshaler); ok {
- return data
- }
- ec.Errorf(ctx, `unexpected type %T from directive, should be graphql.Marshaler`, tmp)
- return graphql.Null
-{{end}}
-
-{{ if .Directives.LocationDirectives "QUERY" }}
-func (ec *executionContext) _queryMiddleware(ctx context.Context, obj *ast.OperationDefinition, next func(ctx context.Context) (interface{}, error)) graphql.Marshaler {
- {{ template "queryDirectives" .Directives.LocationDirectives "QUERY" }}
-}
-{{ end }}
-
-{{ if .Directives.LocationDirectives "MUTATION" }}
-func (ec *executionContext) _mutationMiddleware(ctx context.Context, obj *ast.OperationDefinition, next func(ctx context.Context) (interface{}, error)) graphql.Marshaler {
- {{ template "queryDirectives" .Directives.LocationDirectives "MUTATION" }}
-}
-{{ end }}
-
-{{ if .Directives.LocationDirectives "SUBSCRIPTION" }}
-func (ec *executionContext) _subscriptionMiddleware(ctx context.Context, obj *ast.OperationDefinition, next func(ctx context.Context) (interface{}, error)) func() graphql.Marshaler {
- for _, d := range obj.Directives {
- switch d.Name {
- {{- range $directive := .Directives.LocationDirectives "SUBSCRIPTION" }}
- case "{{$directive.Name}}":
- {{- if $directive.Args }}
- rawArgs := d.ArgumentMap(ec.Variables)
- args, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)
- if err != nil {
- ec.Error(ctx, err)
- return func() graphql.Marshaler {
- return graphql.Null
- }
- }
- {{- end }}
- n := next
- next = func(ctx context.Context) (interface{}, error) {
- return ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})
- }
- {{- end }}
- }
- }
- tmp, err := next(ctx)
- if err != nil {
- ec.Error(ctx, err)
- return func() graphql.Marshaler {
- return graphql.Null
- }
- }
- if data, ok := tmp.(func() graphql.Marshaler); ok {
- return data
- }
- ec.Errorf(ctx, `unexpected type %T from directive, should be graphql.Marshaler`, tmp)
- return func() graphql.Marshaler {
- return graphql.Null
- }
-}
-{{ end }}
-
-{{ if .Directives.LocationDirectives "FIELD" }}
- func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) interface{} {
- {{- if .Directives.LocationDirectives "FIELD" }}
- rctx := graphql.GetResolverContext(ctx)
- for _, d := range rctx.Field.Directives {
- switch d.Name {
- {{- range $directive := .Directives.LocationDirectives "FIELD" }}
- case "{{$directive.Name}}":
- {{- if $directive.Args }}
- rawArgs := d.ArgumentMap(ec.Variables)
- args, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)
- if err != nil {
- ec.Error(ctx, err)
- return nil
- }
- {{- end }}
- n := next
- next = func(ctx context.Context) (interface{}, error) {
- return ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})
- }
- {{- end }}
- }
- }
- {{- end }}
- res, err := ec.ResolverMiddleware(ctx, next)
- if err != nil {
- ec.Error(ctx, err)
- return nil
- }
- return res
- }
-{{ end }}