Class ResourceDocumentSource

java.lang.Object
org.springframework.graphql.support.ResourceDocumentSource
All Implemented Interfaces:
DocumentSource

public class ResourceDocumentSource extends Object implements DocumentSource
DocumentSource that looks for a document Resource under a set of locations and trying a number of different file extension.
Since:
1.0.0
Author:
Rossen Stoyanchev
  • Field Details

    • FILE_EXTENSIONS

      public static final List<String> FILE_EXTENSIONS
      The default file extensions, ".graphql" and ".gql".
  • Constructor Details

    • ResourceDocumentSource

      public ResourceDocumentSource()
      Default constructor that sets the location to "classpath:graphql/" and the extensions to ".graphql" and ".gql".
    • ResourceDocumentSource

      public ResourceDocumentSource(List<Resource> locations, List<String> extensions)
      Constructor with given locations and extensions.
  • Method Details

    • getLocations

      public List<Resource> getLocations()
      Return a read-only list with the configured locations where to check for documents.
    • getExtensions

      public List<String> getExtensions()
      Return a read-only list with the file extensions to try when checking for documents by name.
    • getDocument

      public reactor.core.publisher.Mono<String> getDocument(String name)
      Description copied from interface: DocumentSource
      Return the document that matches the given name.
      Specified by:
      getDocument in interface DocumentSource
      Parameters:
      name - the name to use for the lookup
      Returns:
      Mono that completes either with the document content or with an error, but never empty.