From b478cd1bcb4756b20f7f4b15fcf81f23e1a60a02 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Fri, 14 Sep 2018 12:40:31 +0200 Subject: graphql: update gqlgen to 0.5.1 fix #6 --- .../gqlgen/codegen/templates/generated.gotpl | 175 --------------------- 1 file changed, 175 deletions(-) delete mode 100644 vendor/github.com/vektah/gqlgen/codegen/templates/generated.gotpl (limited to 'vendor/github.com/vektah/gqlgen/codegen/templates/generated.gotpl') diff --git a/vendor/github.com/vektah/gqlgen/codegen/templates/generated.gotpl b/vendor/github.com/vektah/gqlgen/codegen/templates/generated.gotpl deleted file mode 100644 index cc1dc459..00000000 --- a/vendor/github.com/vektah/gqlgen/codegen/templates/generated.gotpl +++ /dev/null @@ -1,175 +0,0 @@ -// Code generated by github.com/vektah/gqlgen, DO NOT EDIT. - -package {{ .PackageName }} - -import ( -{{- range $import := .Imports }} - {{- $import.Write }} -{{ end }} -) - -// MakeExecutableSchema creates an ExecutableSchema from the Resolvers interface. -func MakeExecutableSchema(resolvers Resolvers) graphql.ExecutableSchema { - return &executableSchema{resolvers: resolvers} -} - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(resolvers ResolverRoot) graphql.ExecutableSchema { - return MakeExecutableSchema(shortMapper{r: resolvers}) -} - -type Resolvers interface { -{{- range $object := .Objects -}} - {{ range $field := $object.Fields -}} - {{ $field.ResolverDeclaration }} - {{ end }} -{{- end }} -} - -type ResolverRoot interface { -{{- range $object := .Objects -}} - {{ if $object.HasResolvers -}} - {{$object.GQLType}}() {{$object.GQLType}}Resolver - {{ end }} -{{- end }} -} - -{{- range $object := .Objects -}} - {{ if $object.HasResolvers }} - type {{$object.GQLType}}Resolver interface { - {{ range $field := $object.Fields -}} - {{ $field.ShortResolverDeclaration }} - {{ end }} - } - {{- end }} -{{- end }} - -type shortMapper struct { - r ResolverRoot -} - -{{- range $object := .Objects -}} - {{ range $field := $object.Fields -}} - {{- if $field.IsResolver }} - func (s shortMapper) {{ $field.ResolverDeclaration }} { - return s.r.{{$field.ShortInvocation}} - } - {{- end }} - {{ end }} -{{- end }} - -type executableSchema struct { - resolvers Resolvers -} - -func (e *executableSchema) Schema() *schema.Schema { - return parsedSchema -} - -func (e *executableSchema) Query(ctx context.Context, op *query.Operation) *graphql.Response { - {{- if .QueryRoot }} - ec := executionContext{graphql.GetRequestContext(ctx), e.resolvers} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._{{.QueryRoot.GQLType}}(ctx, op.Selections) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - } - {{- else }} - return graphql.ErrorResponse(ctx, "queries are not supported") - {{- end }} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *query.Operation) *graphql.Response { - {{- if .MutationRoot }} - ec := executionContext{graphql.GetRequestContext(ctx), e.resolvers} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._{{.MutationRoot.GQLType}}(ctx, op.Selections) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - } - {{- else }} - return graphql.ErrorResponse(ctx, "mutations are not supported") - {{- end }} -} - -func (e *executableSchema) Subscription(ctx context.Context, op *query.Operation) func() *graphql.Response { - {{- if .SubscriptionRoot }} - ec := executionContext{graphql.GetRequestContext(ctx), e.resolvers} - - next := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.Selections) - if ec.Errors != nil { - return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) - } - - var buf bytes.Buffer - return func() *graphql.Response { - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - buf.Reset() - data := next() - - if data == nil { - return nil - } - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - } - } - {{- else }} - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) - {{- end }} -} - -type executionContext struct { - *graphql.RequestContext - - resolvers Resolvers -} - -{{- range $object := .Objects }} - {{ template "object.gotpl" $object }} - - {{- range $field := $object.Fields }} - {{ template "field.gotpl" $field }} - {{ end }} -{{- end}} - -{{- range $interface := .Interfaces }} - {{ template "interface.gotpl" $interface }} -{{- end }} - -{{- range $input := .Inputs }} - {{ template "input.gotpl" $input }} -{{- end }} - -func (ec *executionContext) introspectSchema() *introspection.Schema { - return introspection.WrapSchema(parsedSchema) -} - -func (ec *executionContext) introspectType(name string) *introspection.Type { - t := parsedSchema.Resolve(name) - if t == nil { - return nil - } - return introspection.WrapType(t) -} - -var parsedSchema = schema.MustParse({{.SchemaRaw|rawQuote}}) -- cgit