-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
asamusev
committed
Jun 18, 2019
1 parent
cfdbc39
commit 69d7e28
Showing
15 changed files
with
270 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
{{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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.