Package 

Annotation InterfaceObjectDirective

  • All Implemented Interfaces:

    
    public @interface InterfaceObjectDirective
    
                        
    directive @interfaceObject on OBJECT

    This directive provides meta information to the router that this entity type defined within this subgraph is an interface in the supergraph. This allows you to extend functionality of an interface across the supergraph without having to implement (or even be aware of) all its implementing types.

    Example: Given an interface that is defined in another subgraph

    interface Product @key(fields: "id") {
      id: ID!
      description: String
    }
    
    type Book implements Product @key(fields: "id") {
      id: ID!
      description: String
      pages: Int!
    }
    
    type Movie implements Product @key(fields: "id") {
      id: ID!
      description: String
      duration: Int!
    }

    We can extend Product entity in our subgraph and a new field directly to it. This will result in making this new field available to ALL implementing types.

    @InterfaceObjectDirective
    data class Product(val id: ID) {
        fun reviews(): List<Review> = TODO()
    }

    Which generates the following subgraph schema

    type Product @key(fields: "id") @interfaceObject {
      id: ID!
      reviews: [Review!]!
    }
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail