org.eclipse.microprofile.graphql.Query Java Examples
The following examples show how to use
org.eclipse.microprofile.graphql.Query.
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 |
@Query public Character character(@Name("name") String name) throws UnknownCharacterException { LOG.log(Level.INFO, "character invoked [{0}]", name); try { SuperHero superHero = heroDB.getHero(name); return superHero; } catch (UnknownHeroException e) { try { Sidekick sidekick = sidekickDB.getSidekick(name); return sidekick; } catch (UnknownSidekickException ex) { throw new UnknownCharacterException(name); } } }
Example #2
Source File: HeroFinder.java From microprofile-graphql with Apache License 2.0 | 5 votes |
@Query public Item getItemById(@Name("id") long id) { LOG.log(Level.INFO, "getItemById invoked [{0}]", id); for (SuperHero hero : allHeroes()) { for (Item item : hero.getEquipment()) { if (id == item.getId()) { return item; } } } return null; }
Example #3
Source File: RequestContextTest.java From quarkus with Apache License 2.0 | 5 votes |
@Query public String foo() { if (!Arc.container().requestContext().isActive()) { throw new ContextNotActiveException(); } return "success"; }
Example #4
Source File: HeroFinder.java From microprofile-graphql with Apache License 2.0 | 5 votes |
@Query public Collection<SuperHero> allHeroesWithSpecificError() throws SuperHeroLookupException { LOG.info("allHeroesWithSpecificError invoked"); List<SuperHero> partialHeroes = new ArrayList<>(); for (SuperHero hero : heroDB.getAllHeroes()) { if (!"Spider Man".equals(hero.getName())) { partialHeroes.add(hero); } } throw new SuperHeroLookupException("Failed to find one or more heroes", partialHeroes); }
Example #5
Source File: HeroFinder.java From microprofile-graphql with Apache License 2.0 | 5 votes |
@Query public Collection<SuperHero> allHeroesWithError() throws GraphQLException { LOG.info("allHeroesWithError invoked"); List<SuperHero> partialHeroes = new ArrayList<>(); for (SuperHero hero : heroDB.getAllHeroes()) { if ("Starlord".equals(hero.getName())) { partialHeroes.add(null); } else { partialHeroes.add(hero); } } throw new GraphQLException("Failed to find one or more heroes", partialHeroes); }
Example #6
Source File: ScalarTestApi.java From microprofile-graphql with Apache License 2.0 | 5 votes |
@Query @Description("Testing transformed date as a response") @DateFormat(value = "dd MMM yyyy") public LocalDate transformedDate(){ String date = "2016-08-16"; return LocalDate.parse(date); }
Example #7
Source File: HeroFinder.java From microprofile-graphql with Apache License 2.0 | 5 votes |
@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 #8
Source File: HeroFinder.java From microprofile-graphql with Apache License 2.0 | 5 votes |
@Query public Collection<SuperHero> allHeroesWithPower(@Name("power") String power) { LOG.log(Level.INFO, "allHeroesWithPower invoked [{0}]", power); return allHeroesByFilter(hero -> { return hero.getSuperPowers().contains(power); }); }
Example #9
Source File: TestEndpoint.java From smallrye-graphql with Apache License 2.0 | 5 votes |
@Query public TestObject getTestObject(String yourname) { String id = UUID.randomUUID().toString(); TestObject testObject = new TestObject(); testObject.setId(id); testObject.setName(yourname); return testObject; }
Example #10
Source File: HeroFinder.java From microprofile-graphql with Apache License 2.0 | 5 votes |
@Query public String getCurrentLocation(@Name("superHero")@Source SuperHero hero) throws GraphQLException { LOG.log(Level.INFO, "currentLocation invoked [{0}]", hero); final String heroName = hero.getName(); return heroLocator.getHeroLocation(heroName) .orElseThrow(() -> { return new GraphQLException("Cannot find location for " + heroName, GraphQLException.ExceptionType.DataFetchingException); }); }
Example #11
Source File: ErrorApi.java From smallrye-graphql with Apache License 2.0 | 4 votes |
@Query public String annotatedCustomBusinessException() { throw new AnnotatedCustomBusinessException(); }
Example #12
Source File: GreetingResource.java From quarkus with Apache License 2.0 | 4 votes |
@Query public Greeting hello() { return new Greeting("hello", LocalTime.of(11, 34)); }
Example #13
Source File: ProfileGraphQLApi.java From smallrye-graphql with Apache License 2.0 | 4 votes |
@Query("profile") @Description("Get a Profile by ID") public Profile getProfile(int profileId) { return ProfileDB.getProfile(profileId); }
Example #14
Source File: ProfileGraphQLApi.java From smallrye-graphql with Apache License 2.0 | 4 votes |
@Query("configurationByName") @Description("Get a configuration by name") public Configuration getByName(@Name("name") ConfigurationEnum name) { return Configuration.getByName(name.toString()); }
Example #15
Source File: AdditionalDateScalarsApi.java From smallrye-graphql with Apache License 2.0 | 4 votes |
@Query public AdditionalDateScalars additionalDateScalars() { return new AdditionalDateScalars(); }
Example #16
Source File: AdditionalDurationScalarsApi.java From smallrye-graphql with Apache License 2.0 | 4 votes |
@Query public AdditionalDurationScalars additionalDurationScalars() { return new AdditionalDurationScalars(); }
Example #17
Source File: FilmResource.java From quarkus-quickstarts with Apache License 2.0 | 4 votes |
@Query @Description("Get a Films from a galaxy far far away") public Film getFilm(@Name("filmId") int id) { return service.getFilm(id); }
Example #18
Source File: GreetingResource.java From quarkus with Apache License 2.0 | 4 votes |
@Query public String message() { return message; }
Example #19
Source File: FilmResource.java From quarkus-quickstarts with Apache License 2.0 | 4 votes |
@Query public List<Hero> getHeroesWithSurname(@DefaultValue("Skywalker") String surname) { return service.getHeroesBySurname(surname); }
Example #20
Source File: MovieTriviaController.java From smallrye-graphql with Apache License 2.0 | 4 votes |
@Query public Set<Movie> moviesDirectedBy(@Name("director") Person director) { return movies.stream().filter(m -> m.getDirector().equals(director)).collect(Collectors.toSet()); }
Example #21
Source File: ErrorApi.java From smallrye-graphql with Apache License 2.0 | 4 votes |
@Query public String customBusinessException() { throw new CustomBusinessException(); }
Example #22
Source File: ErrorApi.java From smallrye-graphql with Apache License 2.0 | 4 votes |
@Query public String unsupportedOperation() { throw new UnsupportedOperationException("dummy-message"); }
Example #23
Source File: DummyGraphQLApi.java From smallrye-graphql with Apache License 2.0 | 4 votes |
@Query(value = "get") public Foo helloQuery() { return foo; }
Example #24
Source File: AnnotationBehavior.java From smallrye-graphql with Apache License 2.0 | 4 votes |
@Query("greeting") String foo();
Example #25
Source File: SecurityTest.java From quarkus with Apache License 2.0 | 4 votes |
@Query @RolesAllowed("fooRole") public String foo() { return "foo"; }
Example #26
Source File: ScalarTestApi.java From microprofile-graphql with Apache License 2.0 | 4 votes |
@Query public String getaway(){ return "Just testing a name that starts with get but is not a getter"; }
Example #27
Source File: ScalarTestApi.java From microprofile-graphql with Apache License 2.0 | 4 votes |
@Query public BasicInterface basicMessageEcho(@Name("input") BasicInput input) { return new BasicType(input.getMessage()); }
Example #28
Source File: ScalarTestApi.java From microprofile-graphql with Apache License 2.0 | 4 votes |
@Query @Id @Name("testId") public String id(){ return getScalarHolder().getId(); }
Example #29
Source File: ScalarTestApi.java From microprofile-graphql with Apache License 2.0 | 4 votes |
@Query @JsonbProperty("testDateTimeObject") public LocalDateTime dateTimeObject(){ return getScalarHolder().getDateTimeObject(); }
Example #30
Source File: ScalarTestApi.java From microprofile-graphql with Apache License 2.0 | 4 votes |
@Query @Name("testTimeObject") public LocalTime timeObject(){ return getScalarHolder().getTimeObject(); }