From b567d2bb28efa888665dbae8e3f635fdc2c86a41 Mon Sep 17 00:00:00 2001 From: Parker Roan Date: Thu, 21 Sep 2023 19:39:58 -0500 Subject: [PATCH 1/7] remove ! from reps definition --- plugin/federation/federation.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/federation/federation.go b/plugin/federation/federation.go index d0ee8435e11..9df9b8a23f7 100644 --- a/plugin/federation/federation.go +++ b/plugin/federation/federation.go @@ -173,7 +173,7 @@ func (f *federation) InjectSourceLate(schema *ast.Schema) *ast.Source { entityResolverInputDefinitions += fmt.Sprintf("\t%s: %s\n", keyField.Field.ToGo(), keyField.Definition.Type.String()) } entityResolverInputDefinitions += "}" - resolvers += fmt.Sprintf("\t%s(reps: [%s!]!): [%s]\n", r.ResolverName, r.InputTypeName, e.Name) + resolvers += fmt.Sprintf("\t%s(reps: [%s]!): [%s]\n", r.ResolverName, r.InputTypeName, e.Name) } else { resolverArgs := "" for _, keyField := range r.KeyFields { From a697a47de44748ba8c077b9d5db1eaa562538bfe Mon Sep 17 00:00:00 2001 From: Parker Roan Date: Thu, 21 Sep 2023 20:05:22 -0500 Subject: [PATCH 2/7] adding tests --- plugin/federation/federation_test.go | 61 +++++++++++++++++++ .../federation/testdata/multi/multi.graphqls | 10 +++ plugin/federation/testdata/multi/multi.yml | 8 +++ 3 files changed, 79 insertions(+) create mode 100644 plugin/federation/testdata/multi/multi.graphqls create mode 100644 plugin/federation/testdata/multi/multi.yml diff --git a/plugin/federation/federation_test.go b/plugin/federation/federation_test.go index 7e8d924290d..6d64c168873 100644 --- a/plugin/federation/federation_test.go +++ b/plugin/federation/federation_test.go @@ -144,6 +144,67 @@ func TestCodeGenerationFederation2(t *testing.T) { require.NoError(t, f.GenerateCode(data)) } +func TestMultiWithOmitPointers(t *testing.T) { + f, cfg := load(t, "testdata/multi/key.yml") + + require.True(t, cfg.OmitSliceElementPointers) + err := f.MutateConfig(cfg) + require.NoError(t, err) + require.Len(t, cfg.Schema.Types["_Entity"].Types, 1) + require.Len(t, f.Entities, 1) + + entityGraphqlGenerated := false + for _, source := range cfg.Sources { + if source.Name != "federation/entity.graphql" { + continue + } + entityGraphqlGenerated = true + require.Contains(t, source.Input, "reps: [HelloByNamesInput]!") + } + require.True(t, entityGraphqlGenerated) +} + +func TestMultiWithoutOmitPointers(t *testing.T) { + staticRepsString := "reps: [HelloByNamesInput]!" + t.Run("OmitSliceElementPointers true", func(t *testing.T) { + f, cfg := load(t, "testdata/multi/key.yml") + cfg.OmitSliceElementPointers = false + err := f.MutateConfig(cfg) + require.NoError(t, err) + require.Len(t, cfg.Schema.Types["_Entity"].Types, 1) + require.Len(t, f.Entities, 1) + + entityGraphqlGenerated := false + for _, source := range cfg.Sources { + if source.Name != "federation/entity.graphql" { + continue + } + entityGraphqlGenerated = true + require.Contains(t, source.Input, staticRepsString) + } + require.True(t, entityGraphqlGenerated) + }) + + t.Run("OmitSliceElementPointers false", func(t *testing.T) { + f, cfg := load(t, "testdata/multi/key.yml") + cfg.OmitSliceElementPointers = false + err := f.MutateConfig(cfg) + require.NoError(t, err) + require.Len(t, cfg.Schema.Types["_Entity"].Types, 1) + require.Len(t, f.Entities, 1) + + entityGraphqlGenerated := false + for _, source := range cfg.Sources { + if source.Name != "federation/entity.graphql" { + continue + } + entityGraphqlGenerated = true + require.Contains(t, source.Input, staticRepsString) + } + require.True(t, entityGraphqlGenerated) + }) +} + func TestInjectSourceLate(t *testing.T) { _, cfg := load(t, "testdata/allthethings/gqlgen.yml") entityGraphqlGenerated := false diff --git a/plugin/federation/testdata/multi/multi.graphqls b/plugin/federation/testdata/multi/multi.graphqls new file mode 100644 index 00000000000..bf37c5a0672 --- /dev/null +++ b/plugin/federation/testdata/multi/multi.graphqls @@ -0,0 +1,10 @@ +extend schema + @link(url: "https://specs.apollo.dev/federation/v2.3", + import: ["@key"]) + +directive @entityResolver(multi: Boolean) on OBJECT + +type Hello @key(fields: "name") @entityResolver(multi: true) { + name: String! + secondary: String! +} diff --git a/plugin/federation/testdata/multi/multi.yml b/plugin/federation/testdata/multi/multi.yml new file mode 100644 index 00000000000..de7843ae8e3 --- /dev/null +++ b/plugin/federation/testdata/multi/multi.yml @@ -0,0 +1,8 @@ +schema: + - "testdata/multi/key.graphqls" +exec: + filename: testdata/multi/generated/exec.go +federation: + version: 2 + filename: testdata/multi/generated/federation.go +omit_slice_element_pointers: true \ No newline at end of file From b0ebf9f7ba0418e2d1c8acbd1de444333f4c8de3 Mon Sep 17 00:00:00 2001 From: Parker Roan Date: Thu, 21 Sep 2023 20:09:22 -0500 Subject: [PATCH 3/7] fixing tests --- plugin/federation/federation_test.go | 30 +++++----------------- plugin/federation/testdata/multi/multi.yml | 2 +- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/plugin/federation/federation_test.go b/plugin/federation/federation_test.go index 6d64c168873..4e42ff8e1fc 100644 --- a/plugin/federation/federation_test.go +++ b/plugin/federation/federation_test.go @@ -144,31 +144,13 @@ func TestCodeGenerationFederation2(t *testing.T) { require.NoError(t, f.GenerateCode(data)) } -func TestMultiWithOmitPointers(t *testing.T) { - f, cfg := load(t, "testdata/multi/key.yml") - - require.True(t, cfg.OmitSliceElementPointers) - err := f.MutateConfig(cfg) - require.NoError(t, err) - require.Len(t, cfg.Schema.Types["_Entity"].Types, 1) - require.Len(t, f.Entities, 1) - - entityGraphqlGenerated := false - for _, source := range cfg.Sources { - if source.Name != "federation/entity.graphql" { - continue - } - entityGraphqlGenerated = true - require.Contains(t, source.Input, "reps: [HelloByNamesInput]!") - } - require.True(t, entityGraphqlGenerated) -} - -func TestMultiWithoutOmitPointers(t *testing.T) { +func TestMultiWithOmitSliceElemPointersCfg(t *testing.T) { + //This test is to ensure that the input arguments are not + // changed when cfg.OmitSliceElementPointers is false OR true staticRepsString := "reps: [HelloByNamesInput]!" t.Run("OmitSliceElementPointers true", func(t *testing.T) { - f, cfg := load(t, "testdata/multi/key.yml") - cfg.OmitSliceElementPointers = false + f, cfg := load(t, "testdata/multi/multi.yml") + cfg.OmitSliceElementPointers = true err := f.MutateConfig(cfg) require.NoError(t, err) require.Len(t, cfg.Schema.Types["_Entity"].Types, 1) @@ -186,7 +168,7 @@ func TestMultiWithoutOmitPointers(t *testing.T) { }) t.Run("OmitSliceElementPointers false", func(t *testing.T) { - f, cfg := load(t, "testdata/multi/key.yml") + f, cfg := load(t, "testdata/multi/multi.yml") cfg.OmitSliceElementPointers = false err := f.MutateConfig(cfg) require.NoError(t, err) diff --git a/plugin/federation/testdata/multi/multi.yml b/plugin/federation/testdata/multi/multi.yml index de7843ae8e3..891466c73f6 100644 --- a/plugin/federation/testdata/multi/multi.yml +++ b/plugin/federation/testdata/multi/multi.yml @@ -1,5 +1,5 @@ schema: - - "testdata/multi/key.graphqls" + - "testdata/multi/multi.graphqls" exec: filename: testdata/multi/generated/exec.go federation: From e991288e094ed2e6e94ed039c2f918f94b926b4f Mon Sep 17 00:00:00 2001 From: Parker Roan Date: Thu, 21 Sep 2023 22:26:40 -0500 Subject: [PATCH 4/7] adding documentation --- plugin/federation/readme.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin/federation/readme.md b/plugin/federation/readme.md index 4333ed47979..d5dd0628a3f 100644 --- a/plugin/federation/readme.md +++ b/plugin/federation/readme.md @@ -37,3 +37,6 @@ func (r *entityResolver) FindManyMultiHellosByName(ctx context.Context, reps []* /// } ``` + +**Note:** +If you are using `omit_slice_element_pointers: true` option in your config yaml, your `GetMany` resolver will still generate in the example above the same signature `FindManyMultiHellosByName(ctx context.Context, reps []*generated.ManyMultiHellosByNameInput) ([]*generated.MultiHello, error)`. But all other instances will continue to honor `omit_slice_element_pointers: true` \ No newline at end of file From 9abb71c0d30797803df0b9e181252a12477b896f Mon Sep 17 00:00:00 2001 From: Parker Roan Date: Fri, 22 Sep 2023 10:53:59 -0500 Subject: [PATCH 5/7] addressing lint --- plugin/federation/federation_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin/federation/federation_test.go b/plugin/federation/federation_test.go index 4e42ff8e1fc..cc5b20ee3bc 100644 --- a/plugin/federation/federation_test.go +++ b/plugin/federation/federation_test.go @@ -144,9 +144,10 @@ func TestCodeGenerationFederation2(t *testing.T) { require.NoError(t, f.GenerateCode(data)) } +// This test is to ensure that the input arguments are not +// changed when cfg.OmitSliceElementPointers is false OR true func TestMultiWithOmitSliceElemPointersCfg(t *testing.T) { - //This test is to ensure that the input arguments are not - // changed when cfg.OmitSliceElementPointers is false OR true + staticRepsString := "reps: [HelloByNamesInput]!" t.Run("OmitSliceElementPointers true", func(t *testing.T) { f, cfg := load(t, "testdata/multi/multi.yml") From 6d75295c751fac99c83edb6ac3b8eb4521dfd2e6 Mon Sep 17 00:00:00 2001 From: Parker Roan Date: Sun, 24 Sep 2023 20:32:07 -0500 Subject: [PATCH 6/7] commit after go gonerate --- codegen/testserver/followschema/models-gen.go | 2 +- codegen/testserver/singlefile/models-gen.go | 2 +- graphql/executable_schema_mock.go | 41 ++++--- .../testdata/entityresolver/generated/exec.go | 105 ++++++++++-------- 4 files changed, 81 insertions(+), 69 deletions(-) diff --git a/codegen/testserver/followschema/models-gen.go b/codegen/testserver/followschema/models-gen.go index e014c6c67f9..7487ae30c59 100644 --- a/codegen/testserver/followschema/models-gen.go +++ b/codegen/testserver/followschema/models-gen.go @@ -239,7 +239,7 @@ type ValidInput struct { Underscore string `json:"_"` } -// These things are all valid, but without care generate invalid go code +// These things are all valid, but without care generate invalid go code type ValidType struct { DifferentCase string `json:"differentCase"` DifferentCaseOld string `json:"different_case"` diff --git a/codegen/testserver/singlefile/models-gen.go b/codegen/testserver/singlefile/models-gen.go index c0f4fc6e1a9..a2ba890e196 100644 --- a/codegen/testserver/singlefile/models-gen.go +++ b/codegen/testserver/singlefile/models-gen.go @@ -239,7 +239,7 @@ type ValidInput struct { Underscore string `json:"_"` } -// These things are all valid, but without care generate invalid go code +// These things are all valid, but without care generate invalid go code type ValidType struct { DifferentCase string `json:"differentCase"` DifferentCaseOld string `json:"different_case"` diff --git a/graphql/executable_schema_mock.go b/graphql/executable_schema_mock.go index 5e71cb83040..5d7433162fe 100644 --- a/graphql/executable_schema_mock.go +++ b/graphql/executable_schema_mock.go @@ -15,25 +15,25 @@ var _ ExecutableSchema = &ExecutableSchemaMock{} // ExecutableSchemaMock is a mock implementation of ExecutableSchema. // -// func TestSomethingThatUsesExecutableSchema(t *testing.T) { +// func TestSomethingThatUsesExecutableSchema(t *testing.T) { // -// // make and configure a mocked ExecutableSchema -// mockedExecutableSchema := &ExecutableSchemaMock{ -// ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) { -// panic("mock out the Complexity method") -// }, -// ExecFunc: func(ctx context.Context) ResponseHandler { -// panic("mock out the Exec method") -// }, -// SchemaFunc: func() *ast.Schema { -// panic("mock out the Schema method") -// }, -// } +// // make and configure a mocked ExecutableSchema +// mockedExecutableSchema := &ExecutableSchemaMock{ +// ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) { +// panic("mock out the Complexity method") +// }, +// ExecFunc: func(ctx context.Context) ResponseHandler { +// panic("mock out the Exec method") +// }, +// SchemaFunc: func() *ast.Schema { +// panic("mock out the Schema method") +// }, +// } // -// // use mockedExecutableSchema in code that requires ExecutableSchema -// // and then make assertions. +// // use mockedExecutableSchema in code that requires ExecutableSchema +// // and then make assertions. // -// } +// } type ExecutableSchemaMock struct { // ComplexityFunc mocks the Complexity method. ComplexityFunc func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) @@ -95,8 +95,7 @@ func (mock *ExecutableSchemaMock) Complexity(typeName string, fieldName string, // ComplexityCalls gets all the calls that were made to Complexity. // Check the length with: -// -// len(mockedExecutableSchema.ComplexityCalls()) +// len(mockedExecutableSchema.ComplexityCalls()) func (mock *ExecutableSchemaMock) ComplexityCalls() []struct { TypeName string FieldName string @@ -133,8 +132,7 @@ func (mock *ExecutableSchemaMock) Exec(ctx context.Context) ResponseHandler { // ExecCalls gets all the calls that were made to Exec. // Check the length with: -// -// len(mockedExecutableSchema.ExecCalls()) +// len(mockedExecutableSchema.ExecCalls()) func (mock *ExecutableSchemaMock) ExecCalls() []struct { Ctx context.Context } { @@ -162,8 +160,7 @@ func (mock *ExecutableSchemaMock) Schema() *ast.Schema { // SchemaCalls gets all the calls that were made to Schema. // Check the length with: -// -// len(mockedExecutableSchema.SchemaCalls()) +// len(mockedExecutableSchema.SchemaCalls()) func (mock *ExecutableSchemaMock) SchemaCalls() []struct { } { var calls []struct { diff --git a/plugin/federation/testdata/entityresolver/generated/exec.go b/plugin/federation/testdata/entityresolver/generated/exec.go index 0b1e4a60ab7..20ed74ad933 100644 --- a/plugin/federation/testdata/entityresolver/generated/exec.go +++ b/plugin/federation/testdata/entityresolver/generated/exec.go @@ -837,11 +837,11 @@ type Entity { findHelloByName(name: String!,): Hello! findHelloMultiSingleKeysByKey1AndKey2(key1: String!,key2: String!,): HelloMultiSingleKeys! findHelloWithErrorsByName(name: String!,): HelloWithErrors! - findManyMultiHelloByNames(reps: [MultiHelloByNamesInput!]!): [MultiHello] - findManyMultiHelloMultipleRequiresByNames(reps: [MultiHelloMultipleRequiresByNamesInput!]!): [MultiHelloMultipleRequires] - findManyMultiHelloRequiresByNames(reps: [MultiHelloRequiresByNamesInput!]!): [MultiHelloRequires] - findManyMultiHelloWithErrorByNames(reps: [MultiHelloWithErrorByNamesInput!]!): [MultiHelloWithError] - findManyMultiPlanetRequiresNestedByNames(reps: [MultiPlanetRequiresNestedByNamesInput!]!): [MultiPlanetRequiresNested] + findManyMultiHelloByNames(reps: [MultiHelloByNamesInput]!): [MultiHello] + findManyMultiHelloMultipleRequiresByNames(reps: [MultiHelloMultipleRequiresByNamesInput]!): [MultiHelloMultipleRequires] + findManyMultiHelloRequiresByNames(reps: [MultiHelloRequiresByNamesInput]!): [MultiHelloRequires] + findManyMultiHelloWithErrorByNames(reps: [MultiHelloWithErrorByNamesInput]!): [MultiHelloWithError] + findManyMultiPlanetRequiresNestedByNames(reps: [MultiPlanetRequiresNestedByNamesInput]!): [MultiPlanetRequiresNested] findPlanetMultipleRequiresByName(name: String!,): PlanetMultipleRequires! findPlanetRequiresByName(name: String!,): PlanetRequires! findPlanetRequiresNestedByName(name: String!,): PlanetRequiresNested! @@ -943,7 +943,7 @@ func (ec *executionContext) field_Entity_findManyMultiHelloByNames_args(ctx cont var arg0 []*model.MultiHelloByNamesInput if tmp, ok := rawArgs["reps"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reps")) - arg0, err = ec.unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInputᚄ(ctx, tmp) + arg0, err = ec.unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx, tmp) if err != nil { return nil, err } @@ -958,7 +958,7 @@ func (ec *executionContext) field_Entity_findManyMultiHelloMultipleRequiresByNam var arg0 []*model.MultiHelloMultipleRequiresByNamesInput if tmp, ok := rawArgs["reps"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reps")) - arg0, err = ec.unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInputᚄ(ctx, tmp) + arg0, err = ec.unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx, tmp) if err != nil { return nil, err } @@ -973,7 +973,7 @@ func (ec *executionContext) field_Entity_findManyMultiHelloRequiresByNames_args( var arg0 []*model.MultiHelloRequiresByNamesInput if tmp, ok := rawArgs["reps"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reps")) - arg0, err = ec.unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInputᚄ(ctx, tmp) + arg0, err = ec.unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx, tmp) if err != nil { return nil, err } @@ -988,7 +988,7 @@ func (ec *executionContext) field_Entity_findManyMultiHelloWithErrorByNames_args var arg0 []*model.MultiHelloWithErrorByNamesInput if tmp, ok := rawArgs["reps"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reps")) - arg0, err = ec.unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInputᚄ(ctx, tmp) + arg0, err = ec.unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx, tmp) if err != nil { return nil, err } @@ -1003,7 +1003,7 @@ func (ec *executionContext) field_Entity_findManyMultiPlanetRequiresNestedByName var arg0 []*model.MultiPlanetRequiresNestedByNamesInput if tmp, ok := rawArgs["reps"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reps")) - arg0, err = ec.unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInputᚄ(ctx, tmp) + arg0, err = ec.unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx, tmp) if err != nil { return nil, err } @@ -7586,7 +7586,7 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return res } -func (ec *executionContext) unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInputᚄ(ctx context.Context, v interface{}) ([]*model.MultiHelloByNamesInput, error) { +func (ec *executionContext) unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx context.Context, v interface{}) ([]*model.MultiHelloByNamesInput, error) { var vSlice []interface{} if v != nil { vSlice = graphql.CoerceList(v) @@ -7595,7 +7595,7 @@ func (ec *executionContext) unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcom res := make([]*model.MultiHelloByNamesInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNMultiHelloByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx, vSlice[i]) + res[i], err = ec.unmarshalOMultiHelloByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx, vSlice[i]) if err != nil { return nil, err } @@ -7603,12 +7603,7 @@ func (ec *executionContext) unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcom return res, nil } -func (ec *executionContext) unmarshalNMultiHelloByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx context.Context, v interface{}) (*model.MultiHelloByNamesInput, error) { - res, err := ec.unmarshalInputMultiHelloByNamesInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInputᚄ(ctx context.Context, v interface{}) ([]*model.MultiHelloMultipleRequiresByNamesInput, error) { +func (ec *executionContext) unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx context.Context, v interface{}) ([]*model.MultiHelloMultipleRequiresByNamesInput, error) { var vSlice []interface{} if v != nil { vSlice = graphql.CoerceList(v) @@ -7617,7 +7612,7 @@ func (ec *executionContext) unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕ res := make([]*model.MultiHelloMultipleRequiresByNamesInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx, vSlice[i]) + res[i], err = ec.unmarshalOMultiHelloMultipleRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx, vSlice[i]) if err != nil { return nil, err } @@ -7625,12 +7620,7 @@ func (ec *executionContext) unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕ return res, nil } -func (ec *executionContext) unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx context.Context, v interface{}) (*model.MultiHelloMultipleRequiresByNamesInput, error) { - res, err := ec.unmarshalInputMultiHelloMultipleRequiresByNamesInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInputᚄ(ctx context.Context, v interface{}) ([]*model.MultiHelloRequiresByNamesInput, error) { +func (ec *executionContext) unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx context.Context, v interface{}) ([]*model.MultiHelloRequiresByNamesInput, error) { var vSlice []interface{} if v != nil { vSlice = graphql.CoerceList(v) @@ -7639,7 +7629,7 @@ func (ec *executionContext) unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithu res := make([]*model.MultiHelloRequiresByNamesInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNMultiHelloRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx, vSlice[i]) + res[i], err = ec.unmarshalOMultiHelloRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx, vSlice[i]) if err != nil { return nil, err } @@ -7647,12 +7637,7 @@ func (ec *executionContext) unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithu return res, nil } -func (ec *executionContext) unmarshalNMultiHelloRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx context.Context, v interface{}) (*model.MultiHelloRequiresByNamesInput, error) { - res, err := ec.unmarshalInputMultiHelloRequiresByNamesInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInputᚄ(ctx context.Context, v interface{}) ([]*model.MultiHelloWithErrorByNamesInput, error) { +func (ec *executionContext) unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx context.Context, v interface{}) ([]*model.MultiHelloWithErrorByNamesInput, error) { var vSlice []interface{} if v != nil { vSlice = graphql.CoerceList(v) @@ -7661,7 +7646,7 @@ func (ec *executionContext) unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgith res := make([]*model.MultiHelloWithErrorByNamesInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNMultiHelloWithErrorByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx, vSlice[i]) + res[i], err = ec.unmarshalOMultiHelloWithErrorByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx, vSlice[i]) if err != nil { return nil, err } @@ -7669,12 +7654,7 @@ func (ec *executionContext) unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgith return res, nil } -func (ec *executionContext) unmarshalNMultiHelloWithErrorByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx context.Context, v interface{}) (*model.MultiHelloWithErrorByNamesInput, error) { - res, err := ec.unmarshalInputMultiHelloWithErrorByNamesInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInputᚄ(ctx context.Context, v interface{}) ([]*model.MultiPlanetRequiresNestedByNamesInput, error) { +func (ec *executionContext) unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx context.Context, v interface{}) ([]*model.MultiPlanetRequiresNestedByNamesInput, error) { var vSlice []interface{} if v != nil { vSlice = graphql.CoerceList(v) @@ -7683,7 +7663,7 @@ func (ec *executionContext) unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕ res := make([]*model.MultiPlanetRequiresNestedByNamesInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx, vSlice[i]) + res[i], err = ec.unmarshalOMultiPlanetRequiresNestedByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx, vSlice[i]) if err != nil { return nil, err } @@ -7691,11 +7671,6 @@ func (ec *executionContext) unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕ return res, nil } -func (ec *executionContext) unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx context.Context, v interface{}) (*model.MultiPlanetRequiresNestedByNamesInput, error) { - res, err := ec.unmarshalInputMultiPlanetRequiresNestedByNamesInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) marshalNPlanetMultipleRequires2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐPlanetMultipleRequires(ctx context.Context, sel ast.SelectionSet, v model.PlanetMultipleRequires) graphql.Marshaler { return ec._PlanetMultipleRequires(ctx, sel, &v) } @@ -8239,6 +8214,14 @@ func (ec *executionContext) marshalOMultiHello2ᚖgithubᚗcomᚋ99designsᚋgql return ec._MultiHello(ctx, sel, v) } +func (ec *executionContext) unmarshalOMultiHelloByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx context.Context, v interface{}) (*model.MultiHelloByNamesInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMultiHelloByNamesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalOMultiHelloMultipleRequires2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequires(ctx context.Context, sel ast.SelectionSet, v []*model.MultiHelloMultipleRequires) graphql.Marshaler { if v == nil { return graphql.Null @@ -8287,6 +8270,14 @@ func (ec *executionContext) marshalOMultiHelloMultipleRequires2ᚖgithubᚗcom return ec._MultiHelloMultipleRequires(ctx, sel, v) } +func (ec *executionContext) unmarshalOMultiHelloMultipleRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx context.Context, v interface{}) (*model.MultiHelloMultipleRequiresByNamesInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMultiHelloMultipleRequiresByNamesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalOMultiHelloRequires2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequires(ctx context.Context, sel ast.SelectionSet, v []*model.MultiHelloRequires) graphql.Marshaler { if v == nil { return graphql.Null @@ -8335,6 +8326,14 @@ func (ec *executionContext) marshalOMultiHelloRequires2ᚖgithubᚗcomᚋ99desig return ec._MultiHelloRequires(ctx, sel, v) } +func (ec *executionContext) unmarshalOMultiHelloRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx context.Context, v interface{}) (*model.MultiHelloRequiresByNamesInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMultiHelloRequiresByNamesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalOMultiHelloWithError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithError(ctx context.Context, sel ast.SelectionSet, v []*model.MultiHelloWithError) graphql.Marshaler { if v == nil { return graphql.Null @@ -8383,6 +8382,14 @@ func (ec *executionContext) marshalOMultiHelloWithError2ᚖgithubᚗcomᚋ99desi return ec._MultiHelloWithError(ctx, sel, v) } +func (ec *executionContext) unmarshalOMultiHelloWithErrorByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx context.Context, v interface{}) (*model.MultiHelloWithErrorByNamesInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMultiHelloWithErrorByNamesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalOMultiPlanetRequiresNested2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNested(ctx context.Context, sel ast.SelectionSet, v []*model.MultiPlanetRequiresNested) graphql.Marshaler { if v == nil { return graphql.Null @@ -8431,6 +8438,14 @@ func (ec *executionContext) marshalOMultiPlanetRequiresNested2ᚖgithubᚗcomᚋ return ec._MultiPlanetRequiresNested(ctx, sel, v) } +func (ec *executionContext) unmarshalOMultiPlanetRequiresNestedByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx context.Context, v interface{}) (*model.MultiPlanetRequiresNestedByNamesInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMultiPlanetRequiresNestedByNamesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) From 8f771788b3a5f8c4ae65b106cbd80701340634ad Mon Sep 17 00:00:00 2001 From: Steve Coffman Date: Mon, 25 Sep 2023 08:14:23 -0400 Subject: [PATCH 7/7] gofmt Signed-off-by: Steve Coffman --- codegen/testserver/followschema/models-gen.go | 2 +- codegen/testserver/singlefile/models-gen.go | 2 +- graphql/executable_schema_mock.go | 41 ++++++++++--------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/codegen/testserver/followschema/models-gen.go b/codegen/testserver/followschema/models-gen.go index 7487ae30c59..e014c6c67f9 100644 --- a/codegen/testserver/followschema/models-gen.go +++ b/codegen/testserver/followschema/models-gen.go @@ -239,7 +239,7 @@ type ValidInput struct { Underscore string `json:"_"` } -// These things are all valid, but without care generate invalid go code +// These things are all valid, but without care generate invalid go code type ValidType struct { DifferentCase string `json:"differentCase"` DifferentCaseOld string `json:"different_case"` diff --git a/codegen/testserver/singlefile/models-gen.go b/codegen/testserver/singlefile/models-gen.go index a2ba890e196..c0f4fc6e1a9 100644 --- a/codegen/testserver/singlefile/models-gen.go +++ b/codegen/testserver/singlefile/models-gen.go @@ -239,7 +239,7 @@ type ValidInput struct { Underscore string `json:"_"` } -// These things are all valid, but without care generate invalid go code +// These things are all valid, but without care generate invalid go code type ValidType struct { DifferentCase string `json:"differentCase"` DifferentCaseOld string `json:"different_case"` diff --git a/graphql/executable_schema_mock.go b/graphql/executable_schema_mock.go index 5d7433162fe..5e71cb83040 100644 --- a/graphql/executable_schema_mock.go +++ b/graphql/executable_schema_mock.go @@ -15,25 +15,25 @@ var _ ExecutableSchema = &ExecutableSchemaMock{} // ExecutableSchemaMock is a mock implementation of ExecutableSchema. // -// func TestSomethingThatUsesExecutableSchema(t *testing.T) { +// func TestSomethingThatUsesExecutableSchema(t *testing.T) { // -// // make and configure a mocked ExecutableSchema -// mockedExecutableSchema := &ExecutableSchemaMock{ -// ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) { -// panic("mock out the Complexity method") -// }, -// ExecFunc: func(ctx context.Context) ResponseHandler { -// panic("mock out the Exec method") -// }, -// SchemaFunc: func() *ast.Schema { -// panic("mock out the Schema method") -// }, -// } +// // make and configure a mocked ExecutableSchema +// mockedExecutableSchema := &ExecutableSchemaMock{ +// ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) { +// panic("mock out the Complexity method") +// }, +// ExecFunc: func(ctx context.Context) ResponseHandler { +// panic("mock out the Exec method") +// }, +// SchemaFunc: func() *ast.Schema { +// panic("mock out the Schema method") +// }, +// } // -// // use mockedExecutableSchema in code that requires ExecutableSchema -// // and then make assertions. +// // use mockedExecutableSchema in code that requires ExecutableSchema +// // and then make assertions. // -// } +// } type ExecutableSchemaMock struct { // ComplexityFunc mocks the Complexity method. ComplexityFunc func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) @@ -95,7 +95,8 @@ func (mock *ExecutableSchemaMock) Complexity(typeName string, fieldName string, // ComplexityCalls gets all the calls that were made to Complexity. // Check the length with: -// len(mockedExecutableSchema.ComplexityCalls()) +// +// len(mockedExecutableSchema.ComplexityCalls()) func (mock *ExecutableSchemaMock) ComplexityCalls() []struct { TypeName string FieldName string @@ -132,7 +133,8 @@ func (mock *ExecutableSchemaMock) Exec(ctx context.Context) ResponseHandler { // ExecCalls gets all the calls that were made to Exec. // Check the length with: -// len(mockedExecutableSchema.ExecCalls()) +// +// len(mockedExecutableSchema.ExecCalls()) func (mock *ExecutableSchemaMock) ExecCalls() []struct { Ctx context.Context } { @@ -160,7 +162,8 @@ func (mock *ExecutableSchemaMock) Schema() *ast.Schema { // SchemaCalls gets all the calls that were made to Schema. // Check the length with: -// len(mockedExecutableSchema.SchemaCalls()) +// +// len(mockedExecutableSchema.SchemaCalls()) func (mock *ExecutableSchemaMock) SchemaCalls() []struct { } { var calls []struct {