diff options
author | Michael Muré <batolettre@gmail.com> | 2018-12-23 17:11:37 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-12-23 17:11:37 +0100 |
commit | 1410a1af75b1ab9ea3f980a7e372728f9a123abf (patch) | |
tree | e24db8f84c48b20158b1f1fd6d281d700421279c /vendor/github.com/99designs/gqlgen/codegen/templates/generated.gotpl | |
parent | 8fc15a032f021c855abf66ed303c003d57c340ea (diff) | |
download | git-bug-1410a1af75b1ab9ea3f980a7e372728f9a123abf.tar.gz |
upgrade gqlgen to v0.7.1
Diffstat (limited to 'vendor/github.com/99designs/gqlgen/codegen/templates/generated.gotpl')
-rw-r--r-- | vendor/github.com/99designs/gqlgen/codegen/templates/generated.gotpl | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/vendor/github.com/99designs/gqlgen/codegen/templates/generated.gotpl b/vendor/github.com/99designs/gqlgen/codegen/templates/generated.gotpl index 8250bc7a..a37a1613 100644 --- a/vendor/github.com/99designs/gqlgen/codegen/templates/generated.gotpl +++ b/vendor/github.com/99designs/gqlgen/codegen/templates/generated.gotpl @@ -3,9 +3,21 @@ package {{ .PackageName }} import ( -{{- range $import := .Imports }} - {{- $import.Write }} -{{ end }} + %%%IMPORTS%%% + + {{ reserveImport "context" }} + {{ reserveImport "fmt" }} + {{ reserveImport "io" }} + {{ reserveImport "strconv" }} + {{ reserveImport "time" }} + {{ reserveImport "sync" }} + {{ reserveImport "errors" }} + {{ reserveImport "bytes" }} + + {{ reserveImport "github.com/vektah/gqlparser" }} + {{ reserveImport "github.com/vektah/gqlparser/ast" }} + {{ reserveImport "github.com/99designs/gqlgen/graphql" }} + {{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }} ) // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. @@ -126,9 +138,9 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio }) return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - } + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, } {{- else }} return graphql.ErrorResponse(ctx, "queries are not supported") {{- end }} @@ -146,8 +158,9 @@ func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefini }) return &graphql.Response{ - Data: buf, - Errors: ec.Errors, + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, } {{- else }} return graphql.ErrorResponse(ctx, "mutations are not supported") @@ -181,8 +194,9 @@ func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDe } return &graphql.Response{ - Data: buf, - Errors: ec.Errors, + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, } } {{- else }} @@ -250,14 +264,22 @@ func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{} return res } -func (ec *executionContext) introspectSchema() *introspection.Schema { - return introspection.WrapSchema(parsedSchema) +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(parsedSchema), nil } -func (ec *executionContext) introspectType(name string) *introspection.Type { - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]) +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: {{.SchemaFilename|quote}}, Input: {{.SchemaRaw|rawQuote}}}, + {{- range $filename, $schema := .SchemaRaw }} + &ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}}, + {{- end }} ) |