diff --git a/codegen/config/config.go b/codegen/config/config.go index e23d7e9c689..37c5bbc17ab 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -347,7 +347,6 @@ func (c *Config) InjectBuiltins(s *ast.Schema) { "github.com/99designs/gqlgen/graphql.Int32", "github.com/99designs/gqlgen/graphql.Int64", }}, - "Upload": {Model: StringList{"github.com/99designs/gqlgen/graphql.Upload"}}, "ID": { Model: StringList{ "github.com/99designs/gqlgen/graphql.ID", @@ -364,8 +363,9 @@ func (c *Config) InjectBuiltins(s *ast.Schema) { // These are additional types that are injected if defined in the schema as scalars. extraBuiltins := TypeMap{ - "Time": {Model: StringList{"github.com/99designs/gqlgen/graphql.Time"}}, - "Map": {Model: StringList{"github.com/99designs/gqlgen/graphql.Map"}}, + "Time": {Model: StringList{"github.com/99designs/gqlgen/graphql.Time"}}, + "Map": {Model: StringList{"github.com/99designs/gqlgen/graphql.Map"}}, + "Upload": {Model: StringList{"github.com/99designs/gqlgen/graphql.Upload"}}, } for typeName, entry := range extraBuiltins { @@ -379,16 +379,6 @@ func (c *Config) LoadSchema() (*ast.Schema, map[string]string, error) { schemaStrings := map[string]string{} var sources []*ast.Source - - // Add upload scalar - uploadSource := &ast.Source{ - Name: "uploadScalar.graphql", - Input: "\"The `Upload` scalar type represents a multipart file upload.\"\nscalar Upload", - BuiltIn: true, - } - schemaStrings[uploadSource.Name] = uploadSource.Input - sources = append(sources, uploadSource) - for _, filename := range c.SchemaFilename { filename = filepath.ToSlash(filename) var err error diff --git a/example/fileupload/generated.go b/example/fileupload/generated.go index 0fb3ab47f85..05c1a2afc2f 100644 --- a/example/fileupload/generated.go +++ b/example/fileupload/generated.go @@ -43,16 +43,16 @@ type DirectiveRoot struct { type ComplexityRoot struct { File struct { + Content func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int - Content func(childComplexity int) int } Mutation struct { - SingleUpload func(childComplexity int, file graphql.Upload) int - SingleUploadWithPayload func(childComplexity int, req model.UploadFile) int MultipleUpload func(childComplexity int, files []graphql.Upload) int MultipleUploadWithPayload func(childComplexity int, req []model.UploadFile) int + SingleUpload func(childComplexity int, file graphql.Upload) int + SingleUploadWithPayload func(childComplexity int, req model.UploadFile) int } Query struct { @@ -85,6 +85,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { + case "File.Content": + if e.complexity.File.Content == nil { + break + } + + return e.complexity.File.Content(childComplexity), true + case "File.ID": if e.complexity.File.ID == nil { break @@ -99,60 +106,53 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.File.Name(childComplexity), true - case "File.Content": - if e.complexity.File.Content == nil { - break - } - - return e.complexity.File.Content(childComplexity), true - - case "Mutation.SingleUpload": - if e.complexity.Mutation.SingleUpload == nil { + case "Mutation.MultipleUpload": + if e.complexity.Mutation.MultipleUpload == nil { break } - args, err := ec.field_Mutation_singleUpload_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_multipleUpload_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Mutation.SingleUpload(childComplexity, args["file"].(graphql.Upload)), true + return e.complexity.Mutation.MultipleUpload(childComplexity, args["files"].([]graphql.Upload)), true - case "Mutation.SingleUploadWithPayload": - if e.complexity.Mutation.SingleUploadWithPayload == nil { + case "Mutation.MultipleUploadWithPayload": + if e.complexity.Mutation.MultipleUploadWithPayload == nil { break } - args, err := ec.field_Mutation_singleUploadWithPayload_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_multipleUploadWithPayload_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Mutation.SingleUploadWithPayload(childComplexity, args["req"].(model.UploadFile)), true + return e.complexity.Mutation.MultipleUploadWithPayload(childComplexity, args["req"].([]model.UploadFile)), true - case "Mutation.MultipleUpload": - if e.complexity.Mutation.MultipleUpload == nil { + case "Mutation.SingleUpload": + if e.complexity.Mutation.SingleUpload == nil { break } - args, err := ec.field_Mutation_multipleUpload_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_singleUpload_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Mutation.MultipleUpload(childComplexity, args["files"].([]graphql.Upload)), true + return e.complexity.Mutation.SingleUpload(childComplexity, args["file"].(graphql.Upload)), true - case "Mutation.MultipleUploadWithPayload": - if e.complexity.Mutation.MultipleUploadWithPayload == nil { + case "Mutation.SingleUploadWithPayload": + if e.complexity.Mutation.SingleUploadWithPayload == nil { break } - args, err := ec.field_Mutation_multipleUploadWithPayload_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_singleUploadWithPayload_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Mutation.MultipleUploadWithPayload(childComplexity, args["req"].([]model.UploadFile)), true + return e.complexity.Mutation.SingleUploadWithPayload(childComplexity, args["req"].(model.UploadFile)), true case "Query.Empty": if e.complexity.Query.Empty == nil { @@ -238,26 +238,28 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er } var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `# The query type, represents all of the entry points into our object graph + &ast.Source{Name: "schema.graphql", Input: `"The ` + "`" + `Upload` + "`" + ` scalar type represents a multipart file upload." +scalar Upload -# The File type, represents the response of uploading a file +"The ` + "`" + `File` + "`" + ` type, represents the response of uploading a file." type File { id: Int! name: String! content: String! } -# The UploadFile type, represents the request for uploading a file with certain payload +"The ` + "`" + `UploadFile` + "`" + ` type, represents the request for uploading a file with certain payload." input UploadFile { id: Int! file: Upload! } +"The ` + "`" + `Query` + "`" + ` type, represents all of the entry points into our object graph." type Query { empty: String! } -# The mutation type, represents all updates we can make to our data +"The ` + "`" + `Mutation` + "`" + ` type, represents all updates we can make to our data." type Mutation { singleUpload(file: Upload!): File! singleUploadWithPayload(req: UploadFile!): File! @@ -266,8 +268,6 @@ type Mutation { } `}, - &ast.Source{Name: "uploadScalar.graphql", Input: `"The ` + "`" + `Upload` + "`" + ` scalar type represents a multipart file upload." -scalar Upload`}, ) // endregion ************************** generated!.gotpl ************************** @@ -380,9 +380,10 @@ func (ec *executionContext) _File_id(ctx context.Context, field graphql.Collecte ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "File", - Field: field, - Args: nil, + Object: "File", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -406,9 +407,10 @@ func (ec *executionContext) _File_name(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "File", - Field: field, - Args: nil, + Object: "File", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -432,9 +434,10 @@ func (ec *executionContext) _File_content(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "File", - Field: field, - Args: nil, + Object: "File", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -458,9 +461,10 @@ func (ec *executionContext) _Mutation_singleUpload(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Mutation", - Field: field, - Args: nil, + Object: "Mutation", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -491,9 +495,10 @@ func (ec *executionContext) _Mutation_singleUploadWithPayload(ctx context.Contex ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Mutation", - Field: field, - Args: nil, + Object: "Mutation", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -524,9 +529,10 @@ func (ec *executionContext) _Mutation_multipleUpload(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Mutation", - Field: field, - Args: nil, + Object: "Mutation", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -557,9 +563,10 @@ func (ec *executionContext) _Mutation_multipleUploadWithPayload(ctx context.Cont ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Mutation", - Field: field, - Args: nil, + Object: "Mutation", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -590,9 +597,10 @@ func (ec *executionContext) _Query_empty(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -616,9 +624,10 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -646,9 +655,10 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -669,9 +679,10 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -695,9 +706,10 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -718,9 +730,10 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -744,9 +757,10 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -770,9 +784,10 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -796,9 +811,10 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -819,9 +835,10 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -845,9 +862,10 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -868,9 +886,10 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -894,9 +913,10 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -917,9 +937,10 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -943,9 +964,10 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -969,9 +991,10 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -995,9 +1018,10 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1018,9 +1042,10 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1044,9 +1069,10 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1067,9 +1093,10 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1093,9 +1120,10 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1116,9 +1144,10 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1142,9 +1171,10 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1168,9 +1198,10 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1191,9 +1222,10 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1214,9 +1246,10 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1240,9 +1273,10 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1266,9 +1300,10 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1289,9 +1324,10 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1312,9 +1348,10 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1342,9 +1379,10 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1365,9 +1403,10 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1388,9 +1427,10 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1418,9 +1458,10 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1441,9 +1482,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2265,6 +2307,9 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2302,6 +2347,9 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2339,6 +2387,9 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2391,6 +2442,9 @@ func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋg } func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 diff --git a/example/fileupload/model/generated.go b/example/fileupload/model/generated.go index 88136be5e23..c311e9adfe9 100644 --- a/example/fileupload/model/generated.go +++ b/example/fileupload/model/generated.go @@ -6,12 +6,14 @@ import ( "github.com/99designs/gqlgen/graphql" ) +// The `File` type, represents the response of uploading a file. type File struct { ID int `json:"id"` Name string `json:"name"` Content string `json:"content"` } +// The `UploadFile` type, represents the request for uploading a file with certain payload. type UploadFile struct { ID int `json:"id"` File graphql.Upload `json:"file"` diff --git a/example/fileupload/schema.graphql b/example/fileupload/schema.graphql index d5f3067b363..891c61ec93b 100644 --- a/example/fileupload/schema.graphql +++ b/example/fileupload/schema.graphql @@ -1,23 +1,25 @@ -# The query type, represents all of the entry points into our object graph +"The `Upload` scalar type represents a multipart file upload." +scalar Upload -# The File type, represents the response of uploading a file +"The `File` type, represents the response of uploading a file." type File { id: Int! name: String! content: String! } -# The UploadFile type, represents the request for uploading a file with certain payload +"The `UploadFile` type, represents the request for uploading a file with certain payload." input UploadFile { id: Int! file: Upload! } +"The `Query` type, represents all of the entry points into our object graph." type Query { empty: String! } -# The mutation type, represents all updates we can make to our data +"The `Mutation` type, represents all updates we can make to our data." type Mutation { singleUpload(file: Upload!): File! singleUploadWithPayload(req: UploadFile!): File!