Interface GraphQlFieldExec<K>

All Superinterfaces:
AutoCloseable, GraphQlExecCore
All Known Implementing Classes:
GraphQlFieldExecImpl

public interface GraphQlFieldExec<K> extends GraphQlExecCore
Execution for producing the results for a field and its sub-tree in a graphql document. In the initial design, this interface was intended for generating the results for a top-level field, but now it is also used for producing all results for a document. (The document is strictly speaking not a field in graphql terminology, so perhaps it should be renamed to GraphQlNodeExec).
  • Method Details

    • getProcessor

      GraphQlProcessor<K> getProcessor()
      Return the processor from which this instance was created.
    • sendNextItemToWriter

      boolean sendNextItemToWriter(ObjectNotationWriter<K,org.apache.jena.graph.Node> writer) throws IOException
      Send the next item to the writer. If GraphQlExecCore.isSingle() is true then the whole response will be streamed.
      Parameters:
      writer - The object notation writer.
      Returns:
      True iff any data was sent to the writer, false otherwise.
      Throws:
      IOException
    • sendRemainingItemsToWriter

      long sendRemainingItemsToWriter(ObjectNotationWriter<K,org.apache.jena.graph.Node> writer) throws IOException
      This method is likely to be more efficient because it can use Iterator.forEachRemaining.
      Throws:
      IOException
    • writeExtensions

      void writeExtensions(ObjectNotationWriter<K,org.apache.jena.graph.Node> writer, Function<String,K> stringToKey) throws IOException
      Write out data for the extension block of a graphql response. This can be used to expose additional information, such as the underlying SPARQL query.
       {
         "data": ...
         "extensions": {
            "sparqlQuery": "SELECT * { ... }"
         }
       }
       
      Parameters:
      writer - The writer in object state - i.e. .beginObject() must have been called.
      Throws:
      IOException
    • asIterator

      default <T> Iterator<T> asIterator(ObjectNotationWriterInMemory<T,K,org.apache.jena.graph.Node> inMemoryWriter)
      Return an iterator over objects based on sendNextItemToWriter(ObjectNotationWriter). The input data is materalized using the in-memory writer and the produced objects are those returned by the iterator.