From 0adf3e7d2ce4a4ebf5391f888ab35ae0c7d5f2fc Mon Sep 17 00:00:00 2001 From: Hyukjoong Chuck Kim Date: Thu, 5 Oct 2023 08:23:06 +0900 Subject: [PATCH] Add @interfaceObject and @composeDirective at Federation 2 directive lists. Currently, in case of using `@interfaceObject`, in the graphql schema, it generates the directive template at the auto-generated file because those directives are not listed up and not excluded from the generation. So, it causes "not implemented" error on using @interfaceObject even this directive is federation 2.3 nested directive. This commit just adding those directives into the list. Signed-off-by: Hyukjoong Chuck Kim --- plugin/federation/federation.go | 8 +++++++- .../federation/testdata/federation2/federation2.graphql | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugin/federation/federation.go b/plugin/federation/federation.go index 99a1d312b01..7d98850315d 100644 --- a/plugin/federation/federation.go +++ b/plugin/federation/federation.go @@ -85,6 +85,8 @@ func (f *federation) MutateConfig(cfg *config.Config) error { cfg.Directives["inaccessible"] = config.DirectiveConfig{SkipRuntime: true} cfg.Directives["authenticated"] = config.DirectiveConfig{SkipRuntime: true} cfg.Directives["requiresScopes"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["interfaceObject"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["composeDirective"] = config.DirectiveConfig{SkipRuntime: true} } return nil @@ -183,7 +185,11 @@ func (f *federation) InjectSourceLate(schema *ast.Schema) *ast.Source { } entityResolverInputDefinitions += "input " + r.InputTypeName + " {\n" for _, keyField := range r.KeyFields { - entityResolverInputDefinitions += fmt.Sprintf("\t%s: %s\n", keyField.Field.ToGo(), keyField.Definition.Type.String()) + 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) diff --git a/plugin/federation/testdata/federation2/federation2.graphql b/plugin/federation/testdata/federation2/federation2.graphql index 770f8969704..5355cb804c9 100644 --- a/plugin/federation/testdata/federation2/federation2.graphql +++ b/plugin/federation/testdata/federation2/federation2.graphql @@ -1,6 +1,6 @@ extend schema @link(url: "https://specs.apollo.dev/federation/v2.3", - import: ["@key", "@shareable", "@provides", "@external", "@tag", "@extends", "@override", "@inaccessible"]) + import: ["@key", "@shareable", "@provides", "@external", "@tag", "@extends", "@override", "@inaccessible", "@interfaceObject"]) schema { query: CustomQuery @@ -23,4 +23,3 @@ extend type ExternalExtension @key(fields: " upc ") { type CustomQuery { hello: Hello! } -