Search in sources :

Example 1 with SpecifiedByDirective

use of graphql.Directives.SpecifiedByDirective in project graphql-java by graphql-java.

the class SchemaGeneratorHelper method getSpecifiedByUrl.

String getSpecifiedByUrl(ScalarTypeDefinition scalarTypeDefinition, List<ScalarTypeExtensionDefinition> extensions) {
    List<Directive> allDirectives = new ArrayList<>(scalarTypeDefinition.getDirectives());
    extensions.forEach(extension -> allDirectives.addAll(extension.getDirectives()));
    Optional<Directive> specifiedByDirective = FpKit.findOne(allDirectives, directiveDefinition -> directiveDefinition.getName().equals(SpecifiedByDirective.getName()));
    if (!specifiedByDirective.isPresent()) {
        return null;
    }
    Argument urlArgument = specifiedByDirective.get().getArgument("url");
    StringValue url = (StringValue) urlArgument.getValue();
    return url.getValue();
}
Also used : GraphQLArgument(graphql.schema.GraphQLArgument) Argument(graphql.language.Argument) ArrayList(java.util.ArrayList) StringValue(graphql.language.StringValue) GraphQLAppliedDirective(graphql.schema.GraphQLAppliedDirective) SpecifiedByDirective(graphql.Directives.SpecifiedByDirective) GraphQLDirective(graphql.schema.GraphQLDirective) Directive(graphql.language.Directive)

Aggregations

SpecifiedByDirective (graphql.Directives.SpecifiedByDirective)1 Argument (graphql.language.Argument)1 Directive (graphql.language.Directive)1 StringValue (graphql.language.StringValue)1 GraphQLAppliedDirective (graphql.schema.GraphQLAppliedDirective)1 GraphQLArgument (graphql.schema.GraphQLArgument)1 GraphQLDirective (graphql.schema.GraphQLDirective)1 ArrayList (java.util.ArrayList)1