Annotation ExternalDirective
-
- All Implemented Interfaces:
public @interface ExternalDirective# federation v1 definition directive @external on FIELD_DEFINITION # federation v2 definition directive @external on OBJECT | FIELD_DEFINITIONThe @external directive is used to mark a field as owned by another service. This allows service A to use fields from service B while also knowing at runtime the types of that field. @external directive is only applicable on federated extended types. All the external fields should either be referenced from the @key, @requires or @provides directives field sets.
Due to the smart merging of entity types, Federation v2 no longer requires
@externaldirective on@keyfields and can be safely omitted from the schema.@externaldirective is only required on fields referenced by the@requiresand@providesdirective.Example: Given
@KeyDirective(FieldSet("id")) class Product(val id: String) { @ExternalDirective var externalField: String by Delegates.notNull() @RequiresDirective(FieldSet("externalField")) fun newFunctionality(): String { ... } }should generate
type Product @key(fields : "id") { externalField: String! @external id: String! newFunctionality: String! }