Class GraphQlUtils

java.lang.Object
org.aksw.jenax.graphql.sparql.v2.util.GraphQlUtils

public class GraphQlUtils extends Object
  • Constructor Details

    • GraphQlUtils

      public GraphQlUtils()
  • Method Details

    • replaceDirectivesOld

      public static <T extends graphql.language.Node<T>> T replaceDirectivesOld(T node, graphql.util.TraverserContext<graphql.language.Node> context, BiFunction<T,List<graphql.language.Directive>,T> transform, LinkedList<graphql.language.Directive> remainingDirectives)
      Creates a copy of a node with the given list of directives. Returns the new node. replaceDirectives(node, context, (n, newDirectives) -> n.transform(builder -> builder.directives(newDirectives)), remainingDirectives)
    • replaceDirectives

      public static <T extends graphql.language.Node<T>> T replaceDirectives(T node, graphql.util.TraverserContext<graphql.language.Node> context, Function<T,Function<List<graphql.language.Directive>,T>> transform, List<graphql.language.Directive> remainingDirectives)
    • directivesSetterField

      public static Function<List<graphql.language.Directive>,graphql.language.Field> directivesSetterField(graphql.language.Field node)
    • directivesSetterFieldDefinition

      public static Function<List<graphql.language.Directive>,graphql.language.FieldDefinition> directivesSetterFieldDefinition(graphql.language.FieldDefinition node)
    • hasQueryDirective

      public static boolean hasQueryDirective(graphql.language.Document document, String directiveName)
      FIXME Update to the graphqls pec
    • getQueryDirectives

      public static List<graphql.language.Directive> getQueryDirectives(graphql.language.Document document, String directiveName)
    • tryGetNode

      public static Optional<graphql.language.Node<?>> tryGetNode(graphql.language.Node<?> node, String... path)
    • getNumber

      public static Number getNumber(graphql.language.Node<?> node, String... path)
    • getLong

      public static Long getLong(graphql.language.Node<?> node, String... path)
    • getString

      public static String getString(graphql.language.Node<?> node, String... path)
    • toNodeValue

      public static org.apache.jena.sparql.expr.NodeValue toNodeValue(graphql.language.Node<?> node)
      Bridge graphql nodes to jena NodeValues (the latter has a nicer API)
    • toScalarValue

      public static graphql.language.ScalarValue<?> toScalarValue(org.apache.jena.sparql.expr.NodeValue nv)
    • getArgAsBoolean

      public static Boolean getArgAsBoolean(graphql.language.Directive directive, String argName)
    • getArgAsString

      public static String getArgAsString(graphql.language.Directive directive, String argName)
    • getArgAsStrings

      public static List<String> getArgAsStrings(graphql.language.Directive directive, String argName)
      Expand strings to lists
    • toString

      public static String toString(graphql.language.Node<?> node)
    • toBoolean

      public static Boolean toBoolean(graphql.language.Node<?> node)
    • toNumber

      public static Number toNumber(graphql.language.Node<?> node)
    • toLong

      public static Long toLong(graphql.language.Node<?> node)
    • indexArguments

      public static graphql.com.google.common.collect.Multimap<String,graphql.language.Value<?>> indexArguments(graphql.language.Field field)
    • indexValues

      public static graphql.com.google.common.collect.Multimap<String,graphql.language.Value<?>> indexValues(graphql.language.ObjectValue field)
    • getValue

      public static graphql.language.Value<?> getValue(graphql.language.Argument arg)
    • getArgAsLong

      public static Long getArgAsLong(graphql.language.Field field, String name, Map<String,graphql.language.Value<?>> assignments)
    • getArgAsLong

      public static Long getArgAsLong(List<graphql.language.Argument> arguments, String name, Map<String,graphql.language.Value<?>> assignments)
    • findArgument

      public static graphql.language.Argument findArgument(List<graphql.language.Argument> arguments, String name)
    • getArgValue

      public static graphql.language.Value<?> getArgValue(graphql.language.Directive directive, String argName)
    • getArgValueAsString

      public static String getArgValueAsString(graphql.language.Directive directive, String argName, Map<String,graphql.language.Value<?>> assignments)
    • getArgAsBoolean

      public static Boolean getArgAsBoolean(graphql.language.Directive directive, String argName, Map<String,graphql.language.Value<?>> assignments)
    • resolveValue

      public static graphql.language.Value<?> resolveValue(graphql.language.Value<?> value, Map<String,graphql.language.Value<?>> assignments)
      Resolves variable references once against the given map of assignments. Null if there is no assignment.
    • mapToGraphQl

      public static Map<String,graphql.language.Value<?>> mapToGraphQl(Map<String,org.apache.jena.graph.Node> assignments)
    • mapToJena

      public static Map<String,org.apache.jena.graph.Node> mapToJena(Map<String,graphql.language.Value<?>> assignments)
    • applyTransform

      public static graphql.language.Document applyTransform(graphql.language.Document doc, graphql.language.NodeVisitorStub visitor)
    • println

      public static void println(PrintStream printStream, graphql.language.Document doc)
    • expectAtMostOneDirective

      public static graphql.language.Directive expectAtMostOneDirective(graphql.language.DirectivesContainer<?> container, String name)
    • toArrayValue

      public static graphql.language.ArrayValue toArrayValue(List<String> strs)
    • newArgString

      public static graphql.language.Argument newArgString(String name, String value)
    • newArgBoolean

      public static graphql.language.Argument newArgBoolean(String name, Boolean value)
    • newArgString

      public static graphql.language.Argument newArgString(String name, List<String> values)
    • newDirective

      public static graphql.language.Directive newDirective(String name, graphql.language.Argument... arguments)
    • removeDirectivesByName

      public static void removeDirectivesByName(Collection<graphql.language.Directive> directives, String name)