diff --git a/.gitignore b/.gitignore index 4c24a8cca8..a9712beb0b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,6 @@ /integration/node_modules /integration/schema-fetched.graphql /example/chat/package-lock.json -/codegen/tests/gen +/codegen/gen .idea/ diff --git a/codegen/codegen_test.go b/codegen/codegen_test.go index 0c00888db9..20a2817916 100644 --- a/codegen/codegen_test.go +++ b/codegen/codegen_test.go @@ -18,12 +18,12 @@ func TestGenerateServer(t *testing.T) { id: Int } ` - serverFilename := "tests/gen/" + name + "/server/server.go" + serverFilename := "gen/" + name + "/server/server.go" cfg := Config{ SchemaStr: schema, - Exec: PackageConfig{Filename: "tests/gen/" + name + "/exec.go"}, - Model: PackageConfig{Filename: "tests/gen/" + name + "/model.go"}, - Resolver: PackageConfig{Filename: "tests/gen/" + name + "/resolver.go", Type: "Resolver"}, + Exec: PackageConfig{Filename: "gen/" + name + "/exec.go"}, + Model: PackageConfig{Filename: "gen/" + name + "/model.go"}, + Resolver: PackageConfig{Filename: "gen/" + name + "/resolver.go", Type: "Resolver"}, } _ = syscall.Unlink(cfg.Resolver.Filename) @@ -36,7 +36,7 @@ func TestGenerateServer(t *testing.T) { require.NoError(t, err) conf := loader.Config{} - conf.CreateFromFilenames("tests/gen/"+name, serverFilename) + conf.CreateFromFilenames("gen/"+name, serverFilename) _, err = conf.Load() require.NoError(t, err) diff --git a/codegen/config_test.go b/codegen/config_test.go index ac82eecb01..f4260d6dfb 100644 --- a/codegen/config_test.go +++ b/codegen/config_test.go @@ -17,12 +17,12 @@ func TestLoadConfig(t *testing.T) { }) t.Run("malformed config", func(t *testing.T) { - _, err := LoadConfig("tests/cfg/malformedconfig.yml") + _, err := LoadConfig("testdata/cfg/malformedconfig.yml") require.EqualError(t, err, "unable to parse config: yaml: unmarshal errors:\n line 1: cannot unmarshal !!str `asdf` into codegen.Config") }) t.Run("unknown keys", func(t *testing.T) { - _, err := LoadConfig("tests/cfg/unknownkeys.yml") + _, err := LoadConfig("testdata/cfg/unknownkeys.yml") require.EqualError(t, err, "unable to parse config: yaml: unmarshal errors:\n line 2: field unknown not found in type codegen.Config") }) } @@ -33,7 +33,7 @@ func TestLoadDefaultConfig(t *testing.T) { var cfg *Config t.Run("will find closest match", func(t *testing.T) { - err = os.Chdir(filepath.Join(testDir, "tests", "cfg", "subdir")) + err = os.Chdir(filepath.Join(testDir, "testdata", "cfg", "subdir")) require.NoError(t, err) cfg, err = LoadConfigFromDefaultLocations() @@ -42,7 +42,7 @@ func TestLoadDefaultConfig(t *testing.T) { }) t.Run("will find config in parent dirs", func(t *testing.T) { - err = os.Chdir(filepath.Join(testDir, "tests", "cfg", "otherdir")) + err = os.Chdir(filepath.Join(testDir, "testdata", "cfg", "otherdir")) require.NoError(t, err) cfg, err = LoadConfigFromDefaultLocations() diff --git a/codegen/import_test.go b/codegen/import_test.go index 133049dc55..4a48114bae 100644 --- a/codegen/import_test.go +++ b/codegen/import_test.go @@ -6,37 +6,6 @@ import ( "github.com/stretchr/testify/require" ) -func TestInvalidPackagenames(t *testing.T) { - err := generate("invalid-packagename", ` - type Query { - invalidIdentifier: InvalidIdentifier - } - type InvalidIdentifier { - id: Int! - } - `, TypeMap{ - "InvalidIdentifier": {Model: "github.com/99designs/gqlgen/codegen/tests/invalid-packagename.InvalidIdentifier"}, - }) - - require.NoError(t, err) -} - -func TestImportCollisions(t *testing.T) { - err := generate("complexinput", ` - type Query { - collision: It - } - type It { - id: ID! - } - - `, TypeMap{ - "It": {Model: "github.com/99designs/gqlgen/codegen/tests/introspection.It"}, - }) - - require.NoError(t, err) -} - func TestDeterministicDecollisioning(t *testing.T) { a := Imports{ imports: []*Import{ diff --git a/codegen/input_test.go b/codegen/input_test.go index be2e7da2a6..664eb5ef21 100644 --- a/codegen/input_test.go +++ b/codegen/input_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" + "golang.org/x/tools/go/loader" ) func TestTypeUnionAsInput(t *testing.T) { @@ -32,134 +33,25 @@ func TestTypeInInput(t *testing.T) { require.EqualError(t, err, "model plan failed: Item cannot be used as a field of BookmarkableInput. only input and scalar types are allowed") } -func TestRawMapInputs(t *testing.T) { - err := generate("rawmap", ` - type Query { - mapInput(input: Changes): Boolean - } - input Changes { - a: Int - b: Int - } - `, TypeMap{ - "Changes": {Model: "map[string]interface{}"}, - }) - - require.NoError(t, err) -} - -func TestRecursiveInputType(t *testing.T) { - err := generate("recursiveinput", ` - type Query { - recursive(input: RecursiveInputSlice): Boolean - } - input RecursiveInputSlice { - self: [RecursiveInputSlice!] - } - `, TypeMap{ - "RecursiveInputSlice": {Model: "github.com/99designs/gqlgen/codegen/tests.RecursiveInputSlice"}, - }) - - require.NoError(t, err) -} - -func TestComplexInputTypes(t *testing.T) { - err := generate("complexinput", ` - type Query { - nestedInputs(input: [[OuterInput]] = [[{inner: {id: 1}}]]): Boolean - nestedOutputs: [[OuterObject]] - } - input InnerInput { - id:Int! - } - - input OuterInput { - inner: InnerInput! - } - - type OuterObject { - inner: InnerObject! - } - - type InnerObject { - id: Int! - } - `, TypeMap{ - "Changes": {Model: "map[string]interface{}"}, - }) - - require.NoError(t, err) -} - -func TestKeywordInputFields(t *testing.T) { - err := generate("input_keywords_fields", ` - input Object { - break: String! - default: String! - func: String! - interface: String! - select: String! - case: String! - defer: String! - go: String! - map: String! - struct: String! - chan: String! - else: String! - goto: String! - package: String! - switch: String! - const: String! - fallthrough: String! - if: String! - range: String! - type: String! - continue: String! - for: String! - import: String! - return: String! - var: String! - } - type Query { - test(input: Object): Boolean! - } - `) - - require.NoError(t, err) -} - -func TestInputKeywordArgs(t *testing.T) { - err := generate("input_keyword_args", ` - type Query { - test( - break: String!, - default: String!, - func: String!, - interface: String!, - select: String!, - case: String!, - defer: String!, - go: String!, - map: String!, - struct: String!, - chan: String!, - else: String!, - goto: String!, - package: String!, - switch: String!, - const: String!, - fallthrough: String!, - if: String!, - range: String!, - type: String!, - continue: String!, - for: String!, - import: String!, - return: String!, - var: String!, - ): Boolean! - } - `) - - require.NoError(t, err) +func generate(name string, schema string, typemap ...TypeMap) error { + cfg := Config{ + SchemaStr: schema, + Exec: PackageConfig{Filename: "gen/" + name + "/exec.go"}, + Model: PackageConfig{Filename: "gen/" + name + "/model.go"}, + } + + if len(typemap) > 0 { + cfg.Models = typemap[0] + } + err := Generate(cfg) + if err == nil { + conf := loader.Config{} + conf.Import("github.com/99designs/gqlgen/codegen/testdata/gen/" + name) + + _, err = conf.Load() + if err != nil { + panic(err) + } + } + return err } diff --git a/codegen/interface_test.go b/codegen/interface_test.go deleted file mode 100644 index 184186f502..0000000000 --- a/codegen/interface_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package codegen - -import ( - "testing" - - "syscall" - - "github.com/stretchr/testify/require" - "golang.org/x/tools/go/loader" -) - -func TestShapes(t *testing.T) { - err := generate("shapes", ` - type Query { - shapes: [Shape] - } - interface Shape { - area: Float - } - type Circle implements Shape { - radius: Float - area: Float - } - type Rectangle implements Shape { - length: Float - width: Float - area: Float - } - union ShapeUnion = Circle | Rectangle - `, TypeMap{ - "Shape": {Model: "github.com/99designs/gqlgen/codegen/tests.Shape"}, - "ShapeUnion": {Model: "github.com/99designs/gqlgen/codegen/tests.ShapeUnion"}, - "Circle": {Model: "github.com/99designs/gqlgen/codegen/tests.Circle"}, - "Rectangle": {Model: "github.com/99designs/gqlgen/codegen/tests.Rectangle"}, - }) - - require.NoError(t, err) - -} - -func generate(name string, schema string, typemap ...TypeMap) error { - cfg := Config{ - SchemaStr: schema, - Exec: PackageConfig{Filename: "tests/gen/" + name + "/exec.go"}, - Model: PackageConfig{Filename: "tests/gen/" + name + "/model.go"}, - Resolver: PackageConfig{Filename: "tests/gen/" + name + "/resolver.go", Type: "Resolver"}, - } - - _ = syscall.Unlink(cfg.Resolver.Filename) - - if len(typemap) > 0 { - cfg.Models = typemap[0] - } - err := Generate(cfg) - if err == nil { - conf := loader.Config{} - conf.Import("github.com/99designs/gqlgen/codegen/tests/gen/" + name) - - _, err = conf.Load() - if err != nil { - panic(err) - } - } - return err -} diff --git a/codegen/tests/cfg/gqlgen.yml b/codegen/testdata/cfg/gqlgen.yml similarity index 100% rename from codegen/tests/cfg/gqlgen.yml rename to codegen/testdata/cfg/gqlgen.yml diff --git a/codegen/tests/cfg/malformedconfig.yml b/codegen/testdata/cfg/malformedconfig.yml similarity index 100% rename from codegen/tests/cfg/malformedconfig.yml rename to codegen/testdata/cfg/malformedconfig.yml diff --git a/codegen/tests/cfg/otherdir/.gitkeep b/codegen/testdata/cfg/otherdir/.gitkeep similarity index 100% rename from codegen/tests/cfg/otherdir/.gitkeep rename to codegen/testdata/cfg/otherdir/.gitkeep diff --git a/codegen/tests/cfg/subdir/gqlgen.yaml b/codegen/testdata/cfg/subdir/gqlgen.yaml similarity index 100% rename from codegen/tests/cfg/subdir/gqlgen.yaml rename to codegen/testdata/cfg/subdir/gqlgen.yaml diff --git a/codegen/tests/cfg/unknownkeys.yml b/codegen/testdata/cfg/unknownkeys.yml similarity index 100% rename from codegen/tests/cfg/unknownkeys.yml rename to codegen/testdata/cfg/unknownkeys.yml diff --git a/codegen/tests/element.go b/codegen/testserver/element.go similarity index 97% rename from codegen/tests/element.go rename to codegen/testserver/element.go index 5ba273dcf9..3ddb0ba459 100644 --- a/codegen/tests/element.go +++ b/codegen/testserver/element.go @@ -1,4 +1,4 @@ -package tests +package testserver import ( "context" diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go new file mode 100644 index 0000000000..643ad729f0 --- /dev/null +++ b/codegen/testserver/generated.go @@ -0,0 +1,2366 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package testserver + +import ( + "bytes" + context "context" + fmt "fmt" + strconv "strconv" + + introspection1 "github.com/99designs/gqlgen/codegen/testserver/introspection" + invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename" + graphql "github.com/99designs/gqlgen/graphql" + introspection "github.com/99designs/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser" + ast "github.com/vektah/gqlparser/ast" +) + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + } +} + +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot +} + +type ResolverRoot interface { + Query() QueryResolver +} + +type DirectiveRoot struct { +} +type QueryResolver interface { + InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) + Collision(ctx context.Context) (*introspection1.It, error) + MapInput(ctx context.Context, input *map[string]interface{}) (*bool, error) + Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) + NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) + NestedOutputs(ctx context.Context) ([][]*OuterObject, error) + Keywords(ctx context.Context, input *Keywords) (bool, error) + Shapes(ctx context.Context) ([]*Shape, error) + KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) +} + +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + } +} + +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + return graphql.ErrorResponse(ctx, "mutations are not supported") +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) +} + +type executionContext struct { + *graphql.RequestContext + *executableSchema +} + +var circleImplementors = []string{"Circle", "Shape"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, circleImplementors) + + out := graphql.NewOrderedMap(len(fields)) + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Circle") + case "radius": + out.Values[i] = ec._Circle_radius(ctx, field, obj) + case "area": + out.Values[i] = ec._Circle_area(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + return out +} + +func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "Circle" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Radius, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + return graphql.MarshalFloat(res) +} + +func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "Circle" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Area(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + return graphql.MarshalFloat(res) +} + +var innerObjectImplementors = []string{"InnerObject"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionSet, obj *InnerObject) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, innerObjectImplementors) + + out := graphql.NewOrderedMap(len(fields)) + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("InnerObject") + case "id": + out.Values[i] = ec._InnerObject_id(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + return out +} + +func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "InnerObject" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.ID, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(int) + return graphql.MarshalInt(res) +} + +var invalidIdentifierImplementors = []string{"InvalidIdentifier"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.SelectionSet, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, invalidIdentifierImplementors) + + out := graphql.NewOrderedMap(len(fields)) + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("InvalidIdentifier") + case "id": + out.Values[i] = ec._InvalidIdentifier_id(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + return out +} + +func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "InvalidIdentifier" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.ID, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(int) + return graphql.MarshalInt(res) +} + +var itImplementors = []string{"It"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj *introspection1.It) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, itImplementors) + + out := graphql.NewOrderedMap(len(fields)) + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("It") + case "id": + out.Values[i] = ec._It_id(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + return out +} + +func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection1.It) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "It" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.ID, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalID(res) +} + +var outerObjectImplementors = []string{"OuterObject"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionSet, obj *OuterObject) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, outerObjectImplementors) + + out := graphql.NewOrderedMap(len(fields)) + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("OuterObject") + case "inner": + out.Values[i] = ec._OuterObject_inner(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + return out +} + +func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "OuterObject" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Inner, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(InnerObject) + return ec._InnerObject(ctx, field.Selections, &res) +} + +var queryImplementors = []string{"Query"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, queryImplementors) + + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + }) + + out := graphql.NewOrderedMap(len(fields)) + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "invalidIdentifier": + out.Values[i] = ec._Query_invalidIdentifier(ctx, field) + case "collision": + out.Values[i] = ec._Query_collision(ctx, field) + case "mapInput": + out.Values[i] = ec._Query_mapInput(ctx, field) + case "recursive": + out.Values[i] = ec._Query_recursive(ctx, field) + case "nestedInputs": + out.Values[i] = ec._Query_nestedInputs(ctx, field) + case "nestedOutputs": + out.Values[i] = ec._Query_nestedOutputs(ctx, field) + case "keywords": + out.Values[i] = ec._Query_keywords(ctx, field) + case "shapes": + out.Values[i] = ec._Query_shapes(ctx, field) + case "keywordArgs": + out.Values[i] = ec._Query_keywordArgs(ctx, field) + case "__type": + out.Values[i] = ec._Query___type(ctx, field) + case "__schema": + out.Values[i] = ec._Query___schema(ctx, field) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + return out +} + +func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + Args: nil, + Field: field, + }) + return graphql.Defer(func() (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + userErr := ec.Recover(ctx, r) + ec.Error(ctx, userErr) + ret = graphql.Null + } + }() + + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().InvalidIdentifier(ctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*invalid_packagename.InvalidIdentifier) + if res == nil { + return graphql.Null + } + return ec._InvalidIdentifier(ctx, field.Selections, res) + }) +} + +func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + Args: nil, + Field: field, + }) + return graphql.Defer(func() (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + userErr := ec.Recover(ctx, r) + ec.Error(ctx, userErr) + ret = graphql.Null + } + }() + + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Collision(ctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection1.It) + if res == nil { + return graphql.Null + } + return ec._It(ctx, field.Selections, res) + }) +} + +func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + rawArgs := field.ArgumentMap(ec.Variables) + args := map[string]interface{}{} + var arg0 *map[string]interface{} + if tmp, ok := rawArgs["input"]; ok { + var err error + var ptr1 map[string]interface{} + if tmp != nil { + ptr1 = tmp.(map[string]interface{}) + arg0 = &ptr1 + } + + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["input"] = arg0 + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + }) + return graphql.Defer(func() (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + userErr := ec.Recover(ctx, r) + ec.Error(ctx, userErr) + ret = graphql.Null + } + }() + + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().MapInput(ctx, args["input"].(*map[string]interface{})) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + if res == nil { + return graphql.Null + } + return graphql.MarshalBoolean(*res) + }) +} + +func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + rawArgs := field.ArgumentMap(ec.Variables) + args := map[string]interface{}{} + var arg0 *RecursiveInputSlice + if tmp, ok := rawArgs["input"]; ok { + var err error + var ptr1 RecursiveInputSlice + if tmp != nil { + ptr1, err = UnmarshalRecursiveInputSlice(tmp) + arg0 = &ptr1 + } + + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["input"] = arg0 + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + }) + return graphql.Defer(func() (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + userErr := ec.Recover(ctx, r) + ec.Error(ctx, userErr) + ret = graphql.Null + } + }() + + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Recursive(ctx, args["input"].(*RecursiveInputSlice)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + if res == nil { + return graphql.Null + } + return graphql.MarshalBoolean(*res) + }) +} + +func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + rawArgs := field.ArgumentMap(ec.Variables) + args := map[string]interface{}{} + var arg0 [][]*OuterInput + if tmp, ok := rawArgs["input"]; ok { + var err error + var rawIf1 []interface{} + if tmp != nil { + if tmp1, ok := tmp.([]interface{}); ok { + rawIf1 = tmp1 + } else { + rawIf1 = []interface{}{tmp} + } + } + arg0 = make([][]*OuterInput, len(rawIf1)) + for idx1 := range rawIf1 { + var rawIf2 []interface{} + if rawIf1[idx1] != nil { + if tmp1, ok := rawIf1[idx1].([]interface{}); ok { + rawIf2 = tmp1 + } else { + rawIf2 = []interface{}{rawIf1[idx1]} + } + } + arg0[idx1] = make([]*OuterInput, len(rawIf2)) + for idx2 := range rawIf2 { + var ptr3 OuterInput + if rawIf2[idx2] != nil { + ptr3, err = UnmarshalOuterInput(rawIf2[idx2]) + arg0[idx1][idx2] = &ptr3 + } + } + } + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["input"] = arg0 + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + }) + return graphql.Defer(func() (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + userErr := ec.Recover(ctx, r) + ec.Error(ctx, userErr) + ret = graphql.Null + } + }() + + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().NestedInputs(ctx, args["input"].([][]*OuterInput)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + if res == nil { + return graphql.Null + } + return graphql.MarshalBoolean(*res) + }) +} + +func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + Args: nil, + Field: field, + }) + return graphql.Defer(func() (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + userErr := ec.Recover(ctx, r) + ec.Error(ctx, userErr) + ret = graphql.Null + } + }() + + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().NestedOutputs(ctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([][]*OuterObject) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + arr2 := graphql.Array{} + for idx2 := range res[idx1] { + arr2 = append(arr2, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx2) + defer rctx.Pop() + if res[idx1][idx2] == nil { + return graphql.Null + } + return ec._OuterObject(ctx, field.Selections, res[idx1][idx2]) + }()) + } + return arr2 + }()) + } + return arr1 + }) +} + +func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + rawArgs := field.ArgumentMap(ec.Variables) + args := map[string]interface{}{} + var arg0 *Keywords + if tmp, ok := rawArgs["input"]; ok { + var err error + var ptr1 Keywords + if tmp != nil { + ptr1, err = UnmarshalKeywords(tmp) + arg0 = &ptr1 + } + + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["input"] = arg0 + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + }) + return graphql.Defer(func() (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + userErr := ec.Recover(ctx, r) + ec.Error(ctx, userErr) + ret = graphql.Null + } + }() + + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Keywords(ctx, args["input"].(*Keywords)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(bool) + return graphql.MarshalBoolean(res) + }) +} + +func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + Args: nil, + Field: field, + }) + return graphql.Defer(func() (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + userErr := ec.Recover(ctx, r) + ec.Error(ctx, userErr) + ret = graphql.Null + } + }() + + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Shapes(ctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*Shape) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + if res[idx1] == nil { + return graphql.Null + } + return ec._Shape(ctx, field.Selections, res[idx1]) + }()) + } + return arr1 + }) +} + +func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + rawArgs := field.ArgumentMap(ec.Variables) + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["break"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["break"] = arg0 + var arg1 string + if tmp, ok := rawArgs["default"]; ok { + var err error + arg1, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["default"] = arg1 + var arg2 string + if tmp, ok := rawArgs["func"]; ok { + var err error + arg2, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["func"] = arg2 + var arg3 string + if tmp, ok := rawArgs["interface"]; ok { + var err error + arg3, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["interface"] = arg3 + var arg4 string + if tmp, ok := rawArgs["select"]; ok { + var err error + arg4, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["select"] = arg4 + var arg5 string + if tmp, ok := rawArgs["case"]; ok { + var err error + arg5, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["case"] = arg5 + var arg6 string + if tmp, ok := rawArgs["defer"]; ok { + var err error + arg6, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["defer"] = arg6 + var arg7 string + if tmp, ok := rawArgs["go"]; ok { + var err error + arg7, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["go"] = arg7 + var arg8 string + if tmp, ok := rawArgs["map"]; ok { + var err error + arg8, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["map"] = arg8 + var arg9 string + if tmp, ok := rawArgs["struct"]; ok { + var err error + arg9, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["struct"] = arg9 + var arg10 string + if tmp, ok := rawArgs["chan"]; ok { + var err error + arg10, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["chan"] = arg10 + var arg11 string + if tmp, ok := rawArgs["else"]; ok { + var err error + arg11, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["else"] = arg11 + var arg12 string + if tmp, ok := rawArgs["goto"]; ok { + var err error + arg12, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["goto"] = arg12 + var arg13 string + if tmp, ok := rawArgs["package"]; ok { + var err error + arg13, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["package"] = arg13 + var arg14 string + if tmp, ok := rawArgs["switch"]; ok { + var err error + arg14, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["switch"] = arg14 + var arg15 string + if tmp, ok := rawArgs["const"]; ok { + var err error + arg15, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["const"] = arg15 + var arg16 string + if tmp, ok := rawArgs["fallthrough"]; ok { + var err error + arg16, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["fallthrough"] = arg16 + var arg17 string + if tmp, ok := rawArgs["if"]; ok { + var err error + arg17, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["if"] = arg17 + var arg18 string + if tmp, ok := rawArgs["range"]; ok { + var err error + arg18, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["range"] = arg18 + var arg19 string + if tmp, ok := rawArgs["type"]; ok { + var err error + arg19, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["type"] = arg19 + var arg20 string + if tmp, ok := rawArgs["continue"]; ok { + var err error + arg20, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["continue"] = arg20 + var arg21 string + if tmp, ok := rawArgs["for"]; ok { + var err error + arg21, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["for"] = arg21 + var arg22 string + if tmp, ok := rawArgs["import"]; ok { + var err error + arg22, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["import"] = arg22 + var arg23 string + if tmp, ok := rawArgs["return"]; ok { + var err error + arg23, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["return"] = arg23 + var arg24 string + if tmp, ok := rawArgs["var"]; ok { + var err error + arg24, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["var"] = arg24 + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + }) + return graphql.Defer(func() (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + userErr := ec.Recover(ctx, r) + ec.Error(ctx, userErr) + ret = graphql.Null + } + }() + + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().KeywordArgs(ctx, args["break"].(string), args["default"].(string), args["func"].(string), args["interface"].(string), args["select"].(string), args["case"].(string), args["defer"].(string), args["go"].(string), args["map"].(string), args["struct"].(string), args["chan"].(string), args["else"].(string), args["goto"].(string), args["package"].(string), args["switch"].(string), args["const"].(string), args["fallthrough"].(string), args["if"].(string), args["range"].(string), args["type"].(string), args["continue"].(string), args["for"].(string), args["import"].(string), args["return"].(string), args["var"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(bool) + return graphql.MarshalBoolean(res) + }) +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + rawArgs := field.ArgumentMap(ec.Variables) + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["name"] = arg0 + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "Query" + rctx.Args = args + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.introspectType(args["name"].(string)), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + if res == nil { + return graphql.Null + } + return ec.___Type(ctx, field.Selections, res) +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "Query" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.introspectSchema(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + if res == nil { + return graphql.Null + } + return ec.___Schema(ctx, field.Selections, res) +} + +var rectangleImplementors = []string{"Rectangle", "Shape"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet, obj *Rectangle) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, rectangleImplementors) + + out := graphql.NewOrderedMap(len(fields)) + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Rectangle") + case "length": + out.Values[i] = ec._Rectangle_length(ctx, field, obj) + case "width": + out.Values[i] = ec._Rectangle_width(ctx, field, obj) + case "area": + out.Values[i] = ec._Rectangle_area(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + return out +} + +func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "Rectangle" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Length, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + return graphql.MarshalFloat(res) +} + +func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "Rectangle" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Width, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + return graphql.MarshalFloat(res) +} + +func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "Rectangle" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Area(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + return graphql.MarshalFloat(res) +} + +var __DirectiveImplementors = []string{"__Directive"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) + + out := graphql.NewOrderedMap(len(fields)) + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + return out +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Directive" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Name, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalString(res) +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Directive" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalString(res) +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Directive" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Locations, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]string) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return graphql.MarshalString(res[idx1]) + }()) + } + return arr1 +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Directive" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Args, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 +} + +var __EnumValueImplementors = []string{"__EnumValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) + + out := graphql.NewOrderedMap(len(fields)) + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + return out +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__EnumValue" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Name, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalString(res) +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__EnumValue" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalString(res) +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__EnumValue" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.IsDeprecated, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(bool) + return graphql.MarshalBoolean(res) +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__EnumValue" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.DeprecationReason, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalString(res) +} + +var __FieldImplementors = []string{"__Field"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) + + out := graphql.NewOrderedMap(len(fields)) + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + return out +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Field" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Name, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalString(res) +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Field" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalString(res) +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Field" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Args, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Field" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Type, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + if res == nil { + return graphql.Null + } + return ec.___Type(ctx, field.Selections, res) +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Field" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.IsDeprecated, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(bool) + return graphql.MarshalBoolean(res) +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Field" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.DeprecationReason, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalString(res) +} + +var __InputValueImplementors = []string{"__InputValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) + + out := graphql.NewOrderedMap(len(fields)) + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + return out +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__InputValue" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Name, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalString(res) +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__InputValue" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalString(res) +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__InputValue" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Type, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + if res == nil { + return graphql.Null + } + return ec.___Type(ctx, field.Selections, res) +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__InputValue" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.DefaultValue, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} + +var __SchemaImplementors = []string{"__Schema"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) + + out := graphql.NewOrderedMap(len(fields)) + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + return out +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Schema" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Types(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec.___Type(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Schema" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.QueryType(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + if res == nil { + return graphql.Null + } + return ec.___Type(ctx, field.Selections, res) +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Schema" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.MutationType(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + if res == nil { + return graphql.Null + } + return ec.___Type(ctx, field.Selections, res) +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Schema" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.SubscriptionType(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + if res == nil { + return graphql.Null + } + return ec.___Type(ctx, field.Selections, res) +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Schema" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Directives(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Directive) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec.___Directive(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 +} + +var __TypeImplementors = []string{"__Type"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) + + out := graphql.NewOrderedMap(len(fields)) + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + return out +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Type" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Kind(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalString(res) +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Type" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Name(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Type" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Description(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalString(res) +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + rawArgs := field.ArgumentMap(ec.Variables) + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["includeDeprecated"] = arg0 + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Type" + rctx.Args = args + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Fields(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec.___Field(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Type" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Interfaces(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec.___Type(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Type" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.PossibleTypes(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec.___Type(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + rawArgs := field.ArgumentMap(ec.Variables) + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + } + args["includeDeprecated"] = arg0 + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Type" + rctx.Args = args + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.EnumValues(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Type" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.InputFields(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "__Type" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return obj.OfType(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + if res == nil { + return graphql.Null + } + return ec.___Type(ctx, field.Selections, res) +} + +func (ec *executionContext) _Shape(ctx context.Context, sel ast.SelectionSet, obj *Shape) graphql.Marshaler { + switch obj := (*obj).(type) { + case nil: + return graphql.Null + case *Circle: + return ec._Circle(ctx, sel, obj) + case *Rectangle: + return ec._Rectangle(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSet, obj *ShapeUnion) graphql.Marshaler { + switch obj := (*obj).(type) { + case nil: + return graphql.Null + case *Circle: + return ec._Circle(ctx, sel, obj) + case *Rectangle: + return ec._Rectangle(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +func UnmarshalInnerInput(v interface{}) (InnerInput, error) { + var it InnerInput + var asMap = v.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "id": + var err error + it.ID, err = graphql.UnmarshalInt(v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func UnmarshalKeywords(v interface{}) (Keywords, error) { + var it Keywords + var asMap = v.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "break": + var err error + it.Break, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "default": + var err error + it.Default, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "func": + var err error + it.Func, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "interface": + var err error + it.Interface, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "select": + var err error + it.Select, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "case": + var err error + it.Case, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "defer": + var err error + it.Defer, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "go": + var err error + it.Go, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "map": + var err error + it.Map, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "struct": + var err error + it.Struct, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "chan": + var err error + it.Chan, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "else": + var err error + it.Else, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "goto": + var err error + it.Goto, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "package": + var err error + it.Package, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "switch": + var err error + it.Switch, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "const": + var err error + it.Const, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "fallthrough": + var err error + it.Fallthrough, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "if": + var err error + it.If, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "range": + var err error + it.Range, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "type": + var err error + it.Type, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "continue": + var err error + it.Continue, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "for": + var err error + it.For, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "import": + var err error + it.Import, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "return": + var err error + it.Return, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "var": + var err error + it.Var, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func UnmarshalOuterInput(v interface{}) (OuterInput, error) { + var it OuterInput + var asMap = v.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "inner": + var err error + it.Inner, err = UnmarshalInnerInput(v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func UnmarshalRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { + var it RecursiveInputSlice + var asMap = v.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "self": + var err error + var rawIf1 []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + rawIf1 = tmp1 + } else { + rawIf1 = []interface{}{v} + } + } + it.Self = make([]RecursiveInputSlice, len(rawIf1)) + for idx1 := range rawIf1 { + it.Self[idx1], err = UnmarshalRecursiveInputSlice(rawIf1[idx1]) + } + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) interface{} { + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil + } + return res +} + +func (ec *executionContext) introspectSchema() *introspection.Schema { + return introspection.WrapSchema(parsedSchema) +} + +func (ec *executionContext) introspectType(name string) *introspection.Type { + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]) +} + +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `type Query { + invalidIdentifier: InvalidIdentifier + collision: It + mapInput(input: Changes): Boolean + recursive(input: RecursiveInputSlice): Boolean + nestedInputs(input: [[OuterInput]] = [[{inner: {id: 1}}]]): Boolean + nestedOutputs: [[OuterObject]] + keywords(input: Keywords): Boolean! + shapes: [Shape] +} + +type InvalidIdentifier { + id: Int! +} + +type It { + id: ID! +} + +input Changes { + a: Int + b: Int +} + +input RecursiveInputSlice { + self: [RecursiveInputSlice!] +} + +input InnerInput { + id:Int! +} + +input OuterInput { + inner: InnerInput! +} + +type OuterObject { + inner: InnerObject! +} + +type InnerObject { + id: Int! +} + +input Keywords { + break: String! + default: String! + func: String! + interface: String! + select: String! + case: String! + defer: String! + go: String! + map: String! + struct: String! + chan: String! + else: String! + goto: String! + package: String! + switch: String! + const: String! + fallthrough: String! + if: String! + range: String! + type: String! + continue: String! + for: String! + import: String! + return: String! + var: String! +} + +extend type Query { + keywordArgs( + break: String!, + default: String!, + func: String!, + interface: String!, + select: String!, + case: String!, + defer: String!, + go: String!, + map: String!, + struct: String!, + chan: String!, + else: String!, + goto: String!, + package: String!, + switch: String!, + const: String!, + fallthrough: String!, + if: String!, + range: String!, + type: String!, + continue: String!, + for: String!, + import: String!, + return: String!, + var: String!, + ): Boolean! +} + +interface Shape { + area: Float +} +type Circle implements Shape { + radius: Float + area: Float +} +type Rectangle implements Shape { + length: Float + width: Float + area: Float +} +union ShapeUnion = Circle | Rectangle +`}, +) diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go new file mode 100644 index 0000000000..d055a065ae --- /dev/null +++ b/codegen/testserver/generated_test.go @@ -0,0 +1,17 @@ +//go:generate rm -f resolver.go +//go:generate gorunpkg github.com/99designs/gqlgen + +package testserver + +import ( + "net/http" + "testing" + + "github.com/99designs/gqlgen/handler" +) + +func TestCompiles(t *testing.T) { + http.Handle("/query", handler.GraphQL(NewExecutableSchema(Config{ + Resolvers: &Resolver{}, + }))) +} diff --git a/codegen/testserver/gqlgen.yml b/codegen/testserver/gqlgen.yml new file mode 100644 index 0000000000..d7d70f769d --- /dev/null +++ b/codegen/testserver/gqlgen.yml @@ -0,0 +1,27 @@ +schema: schema.graphql + +exec: + filename: generated.go +model: + filename: models-gen.go +resolver: + filename: resolver.go + type: Resolver + +models: + It: + model: "github.com/99designs/gqlgen/codegen/testserver/introspection.It" + InvalidIdentifier: + model: "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename.InvalidIdentifier" + Changes: + model: "map[string]interface{}" + RecursiveInputSlice: + model: "github.com/99designs/gqlgen/codegen/testserver.RecursiveInputSlice" + Shape: + model: "github.com/99designs/gqlgen/codegen/testserver.Shape" + ShapeUnion: + model: "github.com/99designs/gqlgen/codegen/testserver.ShapeUnion" + Circle: + model: "github.com/99designs/gqlgen/codegen/testserver.Circle" + Rectangle: + model: "github.com/99designs/gqlgen/codegen/testserver.Rectangle" diff --git a/codegen/tests/interfaces.go b/codegen/testserver/interfaces.go similarity index 94% rename from codegen/tests/interfaces.go rename to codegen/testserver/interfaces.go index c8daa47304..a1500ebf4a 100644 --- a/codegen/tests/interfaces.go +++ b/codegen/testserver/interfaces.go @@ -1,4 +1,4 @@ -package tests +package testserver import "math" diff --git a/codegen/tests/introspection/it.go b/codegen/testserver/introspection/it.go similarity index 100% rename from codegen/tests/introspection/it.go rename to codegen/testserver/introspection/it.go diff --git a/codegen/tests/invalid-packagename/invalid-identifier.go b/codegen/testserver/invalid-packagename/invalid-identifier.go similarity index 100% rename from codegen/tests/invalid-packagename/invalid-identifier.go rename to codegen/testserver/invalid-packagename/invalid-identifier.go diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go new file mode 100644 index 0000000000..312aeb6328 --- /dev/null +++ b/codegen/testserver/models-gen.go @@ -0,0 +1,43 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package testserver + +type InnerInput struct { + ID int `json:"id"` +} +type InnerObject struct { + ID int `json:"id"` +} +type Keywords struct { + Break string `json:"break"` + Default string `json:"default"` + Func string `json:"func"` + Interface string `json:"interface"` + Select string `json:"select"` + Case string `json:"case"` + Defer string `json:"defer"` + Go string `json:"go"` + Map string `json:"map"` + Struct string `json:"struct"` + Chan string `json:"chan"` + Else string `json:"else"` + Goto string `json:"goto"` + Package string `json:"package"` + Switch string `json:"switch"` + Const string `json:"const"` + Fallthrough string `json:"fallthrough"` + If string `json:"if"` + Range string `json:"range"` + Type string `json:"type"` + Continue string `json:"continue"` + For string `json:"for"` + Import string `json:"import"` + Return string `json:"return"` + Var string `json:"var"` +} +type OuterInput struct { + Inner InnerInput `json:"inner"` +} +type OuterObject struct { + Inner InnerObject `json:"inner"` +} diff --git a/codegen/tests/recursive.go b/codegen/testserver/recursive.go similarity index 77% rename from codegen/tests/recursive.go rename to codegen/testserver/recursive.go index c3fccea6ba..a9d4ac0511 100644 --- a/codegen/tests/recursive.go +++ b/codegen/testserver/recursive.go @@ -1,4 +1,4 @@ -package tests +package testserver type RecursiveInputSlice struct { Self []RecursiveInputSlice diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go new file mode 100644 index 0000000000..eb52ef5a06 --- /dev/null +++ b/codegen/testserver/resolver.go @@ -0,0 +1,46 @@ +//go:generate gorunpkg github.com/99designs/gqlgen + +package testserver + +import ( + context "context" + + introspection1 "github.com/99designs/gqlgen/codegen/testserver/introspection" + invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename" +) + +type Resolver struct{} + +func (r *Resolver) Query() QueryResolver { + return &queryResolver{r} +} + +type queryResolver struct{ *Resolver } + +func (r *queryResolver) InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) { + panic("not implemented") +} +func (r *queryResolver) Collision(ctx context.Context) (*introspection1.It, error) { + panic("not implemented") +} +func (r *queryResolver) MapInput(ctx context.Context, input *map[string]interface{}) (*bool, error) { + panic("not implemented") +} +func (r *queryResolver) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) { + panic("not implemented") +} +func (r *queryResolver) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) { + panic("not implemented") +} +func (r *queryResolver) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) { + panic("not implemented") +} +func (r *queryResolver) Keywords(ctx context.Context, input *Keywords) (bool, error) { + panic("not implemented") +} +func (r *queryResolver) Shapes(ctx context.Context) ([]*Shape, error) { + panic("not implemented") +} +func (r *queryResolver) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) { + panic("not implemented") +} diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql new file mode 100644 index 0000000000..1ae35d45cb --- /dev/null +++ b/codegen/testserver/schema.graphql @@ -0,0 +1,115 @@ +type Query { + invalidIdentifier: InvalidIdentifier + collision: It + mapInput(input: Changes): Boolean + recursive(input: RecursiveInputSlice): Boolean + nestedInputs(input: [[OuterInput]] = [[{inner: {id: 1}}]]): Boolean + nestedOutputs: [[OuterObject]] + keywords(input: Keywords): Boolean! + shapes: [Shape] +} + +type InvalidIdentifier { + id: Int! +} + +type It { + id: ID! +} + +input Changes { + a: Int + b: Int +} + +input RecursiveInputSlice { + self: [RecursiveInputSlice!] +} + +input InnerInput { + id:Int! +} + +input OuterInput { + inner: InnerInput! +} + +type OuterObject { + inner: InnerObject! +} + +type InnerObject { + id: Int! +} + +input Keywords { + break: String! + default: String! + func: String! + interface: String! + select: String! + case: String! + defer: String! + go: String! + map: String! + struct: String! + chan: String! + else: String! + goto: String! + package: String! + switch: String! + const: String! + fallthrough: String! + if: String! + range: String! + type: String! + continue: String! + for: String! + import: String! + return: String! + var: String! +} + +extend type Query { + keywordArgs( + break: String!, + default: String!, + func: String!, + interface: String!, + select: String!, + case: String!, + defer: String!, + go: String!, + map: String!, + struct: String!, + chan: String!, + else: String!, + goto: String!, + package: String!, + switch: String!, + const: String!, + fallthrough: String!, + if: String!, + range: String!, + type: String!, + continue: String!, + for: String!, + import: String!, + return: String!, + var: String!, + ): Boolean! +} + +interface Shape { + area: Float +} +type Circle implements Shape { + radius: Float + area: Float +} +type Rectangle implements Shape { + length: Float + width: Float + area: Float +} +union ShapeUnion = Circle | Rectangle