All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.morimekta.providence.graphql.gql.GQLDirective Maven / Gradle / Ivy

There is a newer version: 2.7.0
Show newest version
package net.morimekta.providence.graphql.gql;

/**
 * A directive represents some modification on a GQL field. It can for
 * the most part be handled in-line, as the query and arguments are
 * parsed, but may be (some time in the future) required to be kept
 * along the field selection.
 */
public enum GQLDirective {
    /**
     * @include(if: $var)
     *
     * Include the field only if 'if' resolves to true.
     */
    include,
    /**
     * @include(if: $var)
     *
     * Include the field only if 'if' resolves to false.
     */
    skip,
    ;

    /**
     * Find directive by the name, not including the '@'.
     *
     * @param name The directive name.
     * @return The directive, or null if not found.
     */
    public static GQLDirective findByName(String name) {
        for (GQLDirective directive : values()) {
            if (directive.name().equals(name)) {
                return directive;
            }
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy