org.eclipse.microprofile.graphql.DefaultValue Java Examples

The following examples show how to use org.eclipse.microprofile.graphql.DefaultValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HeroFinder.java    From microprofile-graphql with Apache License 2.0 6 votes vote down vote up
@Mutation
@Description("Update an item's powerLevel") 
public Item updateItemPowerLevel(@Name("itemID") long itemID,
                                 @DefaultValue("5") @Name("powerLevel") int newLevel) {
    LOG.log(Level.INFO, "updateItemPowerLevel invoked [{0}],[{1}]", new Object[]{itemID, newLevel});
    Item item = null;
    for (SuperHero hero : allHeroes()) {
        for (Item i : hero.getEquipment()) {
            if (i.getId() == itemID) {
                item = i;
                item.setPowerLevel(newLevel);
            }
        }
    }
    return item;
}
 
Example #2
Source File: HeroFinder.java    From microprofile-graphql with Apache License 2.0 5 votes vote down vote up
@Query
public Collection<SuperHero> allHeroesIn(@DefaultValue("New York, NY") @Name("city") String city) {
    LOG.log(Level.INFO, "allHeroesIn invoked [{0}]", city);
    return allHeroesByFilter(hero -> {
        return city.equals(hero.getPrimaryLocation());
    });
}
 
Example #3
Source File: HeroFinder.java    From microprofile-graphql with Apache License 2.0 5 votes vote down vote up
@Mutation
@Description("Gives a hero new equipment")
public SuperHero provisionHero(@Name("hero") String heroName,
                               @DefaultValue(Item.CAPE) @Name("item") Item item)
        throws UnknownHeroException {
    LOG.log(Level.INFO, "provisionHero invoked [{0}],[{1}]", new Object[]{heroName, item});
    SuperHero hero = heroDB.getHero(heroName);
    if (hero == null) {
        throw new UnknownHeroException(heroName);
    }
    hero.getEquipment().add(item);
    return hero;
}
 
Example #4
Source File: HeroFinder.java    From microprofile-graphql with Apache License 2.0 5 votes vote down vote up
@Name("secretToken")
public Token generateSecretToken(@Source SuperHero hero,
                                  @DefaultValue("true") 
                                  @Name("maskFirstPart") boolean maskFirstPart) throws GraphQLException {
    LOG.log(Level.INFO, "generateSecretToken invoked [{0}],[{1}]", new Object[]{hero,maskFirstPart});
    
    String uuid = UUID.randomUUID().toString();
    if(maskFirstPart){
        return new Token(uuid.substring(0,uuid.length()-4).replaceAll("[A-Za-z0-9]", "*") + uuid.substring(uuid.length()-4,uuid.length()));
    }else{
        return new Token(uuid);
    }
}
 
Example #5
Source File: Item.java    From microprofile-graphql with Apache License 2.0 4 votes vote down vote up
@NonNull
@DefaultValue("An unidentified item")
public void setDescription(String description) {
    this.description = description;
}
 
Example #6
Source File: SourceTestApi.java    From microprofile-graphql with Apache License 2.0 4 votes vote down vote up
public String defaultStringInput(@Source SourceType source, @DefaultValue("Default value") String input) {
    return "Input was: " + input;
}
 
Example #7
Source File: AdditionalDateScalarsApi.java    From smallrye-graphql with Apache License 2.0 4 votes vote down vote up
public java.util.Date dateDefault(@Source AdditionalDateScalars additionalDateScalars,
        @DefaultValue("2006-01-02T15:04:05.876") java.util.Date date) {
    return date;
}
 
Example #8
Source File: AdditionalDateScalarsApi.java    From smallrye-graphql with Apache License 2.0 4 votes vote down vote up
public java.sql.Date sqlDateDefault(@Source AdditionalDateScalars additionalDateScalars,
        @DefaultValue("2006-01-02") java.sql.Date date) {
    return date;
}
 
Example #9
Source File: AdditionalDateScalarsApi.java    From smallrye-graphql with Apache License 2.0 4 votes vote down vote up
public java.sql.Timestamp sqlTimestampDefault(@Source AdditionalDateScalars additionalDateScalars,
        @DefaultValue("2006-01-02T15:04:05.876") java.sql.Timestamp timestamp) {
    return timestamp;
}
 
Example #10
Source File: AdditionalDateScalarsApi.java    From smallrye-graphql with Apache License 2.0 4 votes vote down vote up
public java.sql.Time sqlTimeDefault(@Source AdditionalDateScalars additionalDateScalars,
        @DefaultValue("15:04:05") java.sql.Time time) {
    return time;
}
 
Example #11
Source File: AdditionalDurationScalarsApi.java    From smallrye-graphql with Apache License 2.0 4 votes vote down vote up
public Duration durationDefault(@Source AdditionalDurationScalars additionalDurationScalars,
        @DefaultValue("PT1H2M3S") Duration duration) {
    return duration;
}
 
Example #12
Source File: AdditionalDurationScalarsApi.java    From smallrye-graphql with Apache License 2.0 4 votes vote down vote up
public Period periodDefault(@Source AdditionalDurationScalars additionalDurationScalars,
        @DefaultValue("P1Y2M3D") Period period) {
    return period;
}
 
Example #13
Source File: AdditionalScalarsApi.java    From smallrye-graphql with Apache License 2.0 4 votes vote down vote up
public URL urlDefault(@Source AdditionalScalars additionalScalars, @DefaultValue("https://example.com") URL url) {
    return url;
}
 
Example #14
Source File: AdditionalScalarsApi.java    From smallrye-graphql with Apache License 2.0 4 votes vote down vote up
public URI uriDefault(@Source AdditionalScalars additionalScalars, @DefaultValue("https://example.com") URI uri) {
    return uri;
}
 
Example #15
Source File: AdditionalScalarsApi.java    From smallrye-graphql with Apache License 2.0 4 votes vote down vote up
public UUID uuidDefault(@Source AdditionalScalars additionalScalars,
        @DefaultValue("037f4ba2-6d74-4686-a4ea-90cbd86007c3") UUID uuid) {
    return uuid;
}
 
Example #16
Source File: FilmResource.java    From quarkus-quickstarts with Apache License 2.0 4 votes vote down vote up
@Query
public List<Hero> getHeroesWithSurname(@DefaultValue("Skywalker") String surname) {
    return service.getHeroesBySurname(surname);
}