Skip to content

Commit

Permalink
Add @interfaceObject and @composeDirective at Federation 2 directive …
Browse files Browse the repository at this point in the history
…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 <wangmir@gmail.com>
  • Loading branch information
wangmir committed Oct 4, 2023
1 parent 3ff523b commit 0adf3e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 7 additions & 1 deletion plugin/federation/federation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions plugin/federation/testdata/federation2/federation2.graphql
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,4 +23,3 @@ extend type ExternalExtension @key(fields: " upc ") {
type CustomQuery {
hello: Hello!
}

0 comments on commit 0adf3e7

Please sign in to comment.