Class NormalizedDeferredExecution


  • @ExperimentalApi
    public class NormalizedDeferredExecution
    extends java.lang.Object
    Represents details about the defer execution that can be associated with a ExecutableNormalizedField. Taking this schema as an example:
         type Query { animal: Animal }
         interface Animal { name: String, age: Int }
         type Cat implements Animal { name: String, age: Int }
         type Dog implements Animal { name: String, age: Int }
     
    An ENF can be associated with multiple `NormalizedDeferredExecution`s For example, this query:
         query MyQuery {
             animal {
                 ... @defer {
                     name
                 }
                 ... @defer {
                     name
                 }
             }
         }
     
    Would result in one ENF (name) associated with 2 `NormalizedDeferredExecution` instances. This is relevant for the execution since the field would have to be included in 2 incremental payloads. (I know, there's some duplication here, but this is the current state of the spec. There are some discussions happening around de-duplicating data in scenarios like this, so this behaviour might change in the future). A `NormalizedDeferredExecution` may be associated with a list of possible types For example, this query:
         query MyQuery {
             animal {
                 ... @defer {
                     name
                 }
             }
         }
     
    results in a `NormalizedDeferredExecution` with no label and possible types [Dog, Cat] A `NormalizedDeferredExecution` may be associated with specific types For example, this query:
         query MyQuery {
             animal {
                 ... on Cat @defer {
                     name
                 }
                 ... on Dog {
                     name
                 }
             }
         }
     
    results in a single ENF (name) associated with a `NormalizedDeferredExecution` with only "Cat" as a possible type. This means that, at execution time, `name` should be deferred only if the return object is a "Cat" (but not a if it is a "Dog"). ENFs associated with the same instance of `NormalizedDeferredExecution` will be resolved in the same incremental response payload For example, take these queries:
         query Query1 {
             animal {
                 ... @defer {
                     name
                 }
                 ... @defer {
                     age
                 }
             }
         }
    
         query Query2 {
             animal {
                 ... @defer {
                     name
                     age
                 }
             }
         }
     
    In `Query1`, the ENFs name and age are associated with different instances of `NormalizedDeferredExecution`. This means that, during execution, `name` and `age` can be delivered at different times (if name is resolved faster, it will be delivered first, and vice-versa). In `Query2` the fields will share the same instance of `NormalizedDeferredExecution`. This ensures that, at execution time, the fields are guaranteed to be delivered together. In other words, execution should wait until the slowest field resolves and deliver both fields at the same time.
    • Constructor Detail

      • NormalizedDeferredExecution

        public NormalizedDeferredExecution​(@Nullable
                                           java.lang.String label,
                                           java.util.Set<GraphQLObjectType> possibleTypes)
    • Method Detail

      • getLabel

        @Nullable
        public java.lang.String getLabel()
        Returns:
        the label associated with this defer declaration
      • getPossibleTypes

        public java.util.Set<GraphQLObjectType> getPossibleTypes()
        Returns:
        the concrete object types that are associated with this defer execution