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 Details

    • DirectiveHelpers

      public DirectiveHelpers()
  • Method Details

    • getOptionalDirectiveArgumentString

      public static Optional<String> getOptionalDirectiveArgumentString(graphql.language.DirectivesContainer<?> container, GenerationDirective directive, 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, GenerationDirective directive, 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, GenerationDirective directive, 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, GenerationDirective directive, 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, GenerationDirective directive, 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, GenerationDirective directive, 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, GenerationDirective directive, 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, GenerationDirective directive, 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, GenerationDirective directive, 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.
    • getOptionalObjectFieldByName

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

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

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