Class GraphQlToSparqlConverter

java.lang.Object
org.aksw.jenax.graphql.sparql.GraphQlToSparqlConverter

public class GraphQlToSparqlConverter extends Object
Compiles a graphql query to a GraphQlToSparqlMapping instance. All fields can be qualified with IRIs of properties and classes. Names of unqualified fields are passed to a GraphQlResolver for resolution to IRIs. All resolver methods are allowed to throw UnsupportedOperationException to indicate absence of resolution support.
  • Field Details

    • resolver

      protected GraphQlResolver resolver
    • jsonMode

      protected boolean jsonMode
      false -> rdf mode, true -> json mode
  • Constructor Details

    • GraphQlToSparqlConverter

      public GraphQlToSparqlConverter(GraphQlResolver resolver, boolean jsonMode)
  • Method Details

    • convertDocument

      public GraphQlToSparqlMapping convertDocument(graphql.language.Document document, Map<String,graphql.language.Value<?>> assignments)
    • setupContext

      public static Context setupContext(Context cxt)
      Parses a GraphQL node's rdf annotations.
    • deriveFieldIri

      public static String deriveFieldIri(Context context, String fieldName)
    • processSparqlDirectives

      public static void processSparqlDirectives(Context cxt, GraphQlResolver resolver)
    • tryParseSparqlQuery

      public static org.aksw.jenax.sparql.fragment.api.Fragment tryParseSparqlQuery(Context cxt, graphql.language.Directive dir, String argName)
    • tryParseSlice

      public static com.google.common.collect.Range<Long> tryParseSlice(com.google.common.collect.Multimap<String,graphql.language.Value<?>> args, Map<String,graphql.language.Value<?>> assignments)
      Returns null if neither offset nor limit is found
    • resolveProperty

      public org.aksw.jenax.path.core.FacetPath resolveProperty(Context cxt, String fieldName)
      This method uses the context to resolve a field name to a relative facet path
    • resolveClass

      public static org.apache.jena.graph.Node resolveClass(GraphQlResolver resolver, Context cxt, String fieldName)
    • resolveKeyToClasses

      public NodeQuery resolveKeyToClasses(NodeQuery nq, org.apache.jena.graph.Node cls)
    • tryApplySlice

      public static void tryApplySlice(NodeQuery nodeQuery, com.google.common.collect.Multimap<String,graphql.language.Value<?>> args, Map<String,graphql.language.Value<?>> assignments)
    • tryGetPrefixMap

      public static org.apache.jena.riot.system.PrefixMap tryGetPrefixMap(graphql.language.Value<?> value)
    • getCardinality

      public static ScopedCardinality getCardinality(graphql.language.DirectivesContainer<?> container)
      Returns the last @one or @many directive - null if there is none.
    • getCardinality

      public static ScopedCardinality getCardinality(graphql.language.Directive d)
      Return a cardinality object if the directive is @one or @many - null if neither.