Class DirectiveHelpers

java.lang.Object
no.sikt.graphql.directives.DirectiveHelpers

public class DirectiveHelpers extends Object
Helper methods for extracting directive information from the schema.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Boolean
    getDirectiveArgumentBoolean(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
    Get a directive argument value.
    static String
    getDirectiveArgumentEnum(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
    Get a directive argument value.
    static List<graphql.language.ObjectField>
    getDirectiveArgumentObjectFields(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
    Get a directive argument value.
    static String
    getDirectiveArgumentString(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
    Get a directive argument value.
    static <T extends graphql.language.NamedNode<T>>
    T
    getObjectFieldByName(List<T> fields, no.sikt.graphql.directives.GenerationDirectiveParam param)
     
    getOptionalDirectiveArgumentBoolean(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
     
    getOptionalDirectiveArgumentEnum(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
     
    static Optional<List<graphql.language.ObjectField>>
    getOptionalDirectiveArgumentObjectFields(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
     
    static Optional<List<graphql.language.ObjectValue>>
    getOptionalDirectiveArgumentObjectValueList(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
     
    getOptionalDirectiveArgumentString(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
     
    static List<String>
    getOptionalDirectiveArgumentStringList(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
     
    static <T extends graphql.language.NamedNode<T>>
    Optional<T>
    getOptionalObjectFieldByName(List<T> fields, no.sikt.graphql.directives.GenerationDirectiveParam param)
     
    static List<String>
    getRepeatableDirectiveArgumentString(graphql.language.DirectivesContainer<?> container, String directive, String param)
     
    static String
    stringValueOf(graphql.language.ObjectField objectField)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DirectiveHelpers

      public DirectiveHelpers()
  • Method Details

    • getOptionalDirectiveArgumentString

      public static Optional<String> getOptionalDirectiveArgumentString(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
      Parameters:
      container - The graph element to be inspected.
      directive - The directive this argument should be set on.
      param - Name of the argument.
      Returns:
      The String value of the directive argument, if it exists.
    • getRepeatableDirectiveArgumentString

      public static List<String> getRepeatableDirectiveArgumentString(graphql.language.DirectivesContainer<?> container, String directive, String param)
      Parameters:
      container - The graph element to be inspected.
      directive - The directive this argument should be set on.
      param - Name of the argument.
      Returns:
      The String values of the directive arguments, if they exist.
    • getOptionalDirectiveArgumentEnum

      public static Optional<String> getOptionalDirectiveArgumentEnum(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
      Parameters:
      container - The graph element to be inspected.
      directive - The directive this argument should be set on.
      param - Name of the argument.
      Returns:
      The name of the enum value for this argument, if it exists.
    • getOptionalDirectiveArgumentStringList

      public static List<String> getOptionalDirectiveArgumentStringList(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
      Parameters:
      container - The graph element to be inspected.
      directive - The directive this argument should be set on.
      param - Name of the argument.
      Returns:
      List of String values of the directive argument, if it exists.
    • getOptionalDirectiveArgumentBoolean

      public static Optional<Boolean> getOptionalDirectiveArgumentBoolean(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
      Parameters:
      container - The graph element to be inspected.
      directive - The directive this argument should be set on.
      param - Name of the argument.
      Returns:
      The Boolean value of the directive argument, if it exists.
    • getOptionalDirectiveArgumentObjectFields

      public static Optional<List<graphql.language.ObjectField>> getOptionalDirectiveArgumentObjectFields(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
      Parameters:
      container - The graph element to be inspected.
      directive - The directive this argument should be set on.
      param - Name of the argument.
      Returns:
      Object fields of the directive argument, if it exists.
    • getDirectiveArgumentString

      public static String getDirectiveArgumentString(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
      Get a directive argument value. This assumes that the argument is required and will exist.
      Parameters:
      container - The graph element to be inspected.
      directive - The directive this argument should be set on.
      param - Name of the argument.
      Returns:
      The String value of the directive argument. An exception is thrown if this does not exist.
    • getDirectiveArgumentEnum

      public static String getDirectiveArgumentEnum(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
      Get a directive argument value. This assumes that the argument is required and will exist.
      Parameters:
      container - The graph element to be inspected.
      directive - The directive this argument should be set on.
      param - Name of the argument.
      Returns:
      The name of the enum value for this argument. An exception is thrown if this does not exist.
    • getDirectiveArgumentBoolean

      public static Boolean getDirectiveArgumentBoolean(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
      Get a directive argument value. This assumes that the argument is required and will exist.
      Parameters:
      container - The graph element to be inspected.
      directive - The directive this argument should be set on.
      param - Name of the argument.
      Returns:
      The Boolean value of the directive argument. An exception is thrown if this does not exist.
    • getDirectiveArgumentObjectFields

      public static List<graphql.language.ObjectField> getDirectiveArgumentObjectFields(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
      Get a directive argument value. This assumes that the argument is required and will exist.
      Parameters:
      container - The graph element to be inspected.
      directive - The directive this argument should be set on.
      param - Name of the argument.
      Returns:
      Object fields of the directive argument. An exception is thrown if this does not exist.
    • getOptionalDirectiveArgumentObjectValueList

      public static Optional<List<graphql.language.ObjectValue>> getOptionalDirectiveArgumentObjectValueList(graphql.language.DirectivesContainer<?> container, no.sikt.graphql.directives.GenerationDirective directive, no.sikt.graphql.directives.GenerationDirectiveParam param)
      Parameters:
      container - The graph element to be inspected.
      directive - The directive this argument should be set on.
      param - Name of the argument.
      Returns:
      List of ObjectValue elements from the directive argument, if it exists.
    • getOptionalObjectFieldByName

      public static <T extends graphql.language.NamedNode<T>> Optional<T> getOptionalObjectFieldByName(List<T> fields, no.sikt.graphql.directives.GenerationDirectiveParam param)
    • getObjectFieldByName

      public static <T extends graphql.language.NamedNode<T>> T getObjectFieldByName(List<T> fields, no.sikt.graphql.directives.GenerationDirectiveParam param)
    • stringValueOf

      public static String stringValueOf(graphql.language.ObjectField objectField)