io.leangen.graphql.annotations.GraphQLQuery Java Examples

The following examples show how to use io.leangen.graphql.annotations.GraphQLQuery. 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: UserService.java    From graphql-spqr with Apache License 2.0 6 votes vote down vote up
@GraphQLQuery(name = "users")
public List<User<String>> getUsersById(@GraphQLArgument(name = "id") @GraphQLId Integer id) {
    User<String> user = new User<>();
    user.id = id;
    user.name = "Tatko";
    user.uuid = UUID.randomUUID();
    user.registrationDate = new Date();
    user.addresses = addresses;
    User<String> user2 = new User<>();
    user2.id = id + 1;
    user2.name = "Tzar";
    user2.uuid = UUID.randomUUID();
    user2.registrationDate = new Date();
    user2.addresses = addresses;
    return Arrays.asList(user, user2);
}
 
Example #2
Source File: TypeResolverTest.java    From graphql-spqr with Apache License 2.0 5 votes vote down vote up
@GraphQLQuery(name = "repo")
public List<Stream<GenericRepo>> getRepo(@GraphQLArgument(name = "id") int id) {
    if (id % 2 == 0) {
        return Collections.singletonList(Stream.of(new SessionRepo<>(new Street("Baker street", 1))));
    } else {
        return Collections.singletonList(Stream.of(new SessionRepo<>(new Education("Alma Mater", 1600, 1604))));
    }
}
 
Example #3
Source File: BatchingTest.java    From graphql-spqr with Apache License 2.0 5 votes vote down vote up
@GraphQLQuery(name = "candidates")
public List<SimpleUser> getCandidates() {
    SimpleUser friend = new SimpleUser("Other Guy");
    SimpleUser one = new SimpleUser("One", friend);
    SimpleUser two = new SimpleUser("Two", friend);
    SimpleUser three = new SimpleUser("Three", friend);
    List<SimpleUser> dudes = new ArrayList<>();
    dudes.add(one);
    dudes.add(two);
    dudes.add(three);
    return dudes;
}
 
Example #4
Source File: TypeResolverTest.java    From graphql-spqr with Apache License 2.0 5 votes vote down vote up
@GraphQLQuery
public List<Content> contents() {
    return Arrays.asList(new Trailer2("1", "Argo"),
            new Trailer2("2", "Gravity"),
            new Movie2("3", "The Ring", "R"),
            new Movie2("4", "Brazil", "R"),
            new TVShow2("5", "Simpsons", 1, 2));
}
 
Example #5
Source File: RelayTest.java    From graphql-spqr with Apache License 2.0 5 votes vote down vote up
@GraphQLQuery(name = "extended")
public ExtendedConnection<ExtendedEdge<Book>> getExtended(@GraphQLArgument(name = "first") int first, @GraphQLArgument(name = "after") String after) {
    List<Book> books = new ArrayList<>();
    books.add(new Book("Tesseract", "x123"));
    long count = 100L;
    long offset = Long.parseLong(after);
    Iterator<ExtendedEdge.COLOR> colors = Arrays.asList(ExtendedEdge.COLOR.WHITE, ExtendedEdge.COLOR.BLACK).iterator();
    return PageFactory.createOffsetBasedConnection(books, count, offset,
            (node, cursor) -> new ExtendedEdge<>(node, cursor, colors.next()), (edges, info) -> new ExtendedConnection<>(edges, info, count));
}
 
Example #6
Source File: UserService.java    From graphql-spqr with Apache License 2.0 5 votes vote down vote up
@GraphQLQuery(name = "user")
public User<String> getUserById(@GraphQLId(relayId = true) Integer wonkyName) {
    User<String> user = new User<>();
    user.id = 1;
    user.name = "One Dude";
    user.title = "The One";
    user.uuid = UUID.randomUUID();
    user.registrationDate = new Date();
    user.addresses = addresses;
    return user;
}
 
Example #7
Source File: ArgumentValueTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery
RelayTest.Book findBook(@GraphQLArgument(name = "title", defaultValue = "Monkey") String title) {
    return new RelayTest.Book("The Silent Monkey Club", "x123");
}
 
Example #8
Source File: TypeResolverTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery(name = "identifier")
String identifier();
 
Example #9
Source File: ArgumentInjectionTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery(name = ECHO)
public String echoRootContext(@GraphQLRootContext("target") String target) {
    return target;
}
 
Example #10
Source File: RelayTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery(name = "empty")
public Page<Book> getEmpty(@GraphQLArgument(name = "first") int first, @GraphQLArgument(name = "after") String after) {
    return null;
}
 
Example #11
Source File: ArgumentValueTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery
RelayTest.Book findBook(@GraphQLArgument(name = "author", defaultValue = "Monkey") NestedQueryTest.Author author) {
    return new RelayTest.Book("The Silent Monkey Club", "x123");
}
 
Example #12
Source File: ObjectScalarTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery(name = "processPatches")
public List<JsonPatch> processPatches(@GraphQLArgument(name = "args") List<JsonPatch> patches) {
    return patches;
}
 
Example #13
Source File: PolymorphicJsonTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery(name = "item")
@GraphQLInputField(name = "item")
public abstract T getItem();
 
Example #14
Source File: PolymorphicJsonTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery
public Parent<String> test(@GraphQLArgument(name = "container") Parent<String> container) {
    return container;
}
 
Example #15
Source File: DirectiveTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery
public List<@GraphQLNonNull Book> books(String searchString) {
    return Collections.singletonList(new Book(searchString, "x123"));
}
 
Example #16
Source File: DirectiveTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery
@FieldDef(@Wrapper(name = "fieldDef", value = "test"))
public ObjectResult obj(@ArgDef(@Wrapper(name = "argument", value = "test")) String in) {
    return null;
}
 
Example #17
Source File: ImplementationAutoDiscoveryTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery(name = "one")
public One findOne() {
    return new One();
}
 
Example #18
Source File: NestedQueryTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery(name = "books")
public RelayTest.Book[] getBooks(@GraphQLArgument(name = "after") LocalDate after) {
    return new RelayTest.Book[] {new RelayTest.Book("Tesseract", "x123")};
}
 
Example #19
Source File: TypeResolverTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery
public String rating() {return rating;}
 
Example #20
Source File: TypeResolverTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery
public String rating() {return rating;}
 
Example #21
Source File: RelayTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery
public Page<List<@GraphQLNonNull Book>> getBookLists(@GraphQLArgument(name = "first") int first, @GraphQLArgument(name = "after") String after) {
    return PageFactory.createOffsetBasedPage(Collections.singletonList(Collections.singletonList(new Book("Tesseract", "x123"))), 5, 0);
}
 
Example #22
Source File: RelayTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery(name = "empty")
public Page<Book> getEmpty(@GraphQLArgument(name = "first") int first, @GraphQLArgument(name = "after") String after) {
    return PageFactory.createOffsetBasedPage(Collections.emptyList(), 100, 10);
}
 
Example #23
Source File: NonNullTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery
public Item fieldWithDefault(Item in) {
    return in;
}
 
Example #24
Source File: ArgumentInjectionTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery(name = ECHO)
public @GraphQLScalar Street echoArgument(@GraphQLArgument(name = "user") @GraphQLScalar Street street) {
    return street;
}
 
Example #25
Source File: Robot.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery(name = "id")
public @GraphQLId(relayId = true) String getModel() {
    return model;
}
 
Example #26
Source File: TemporalScalarsTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery(name = "identity")
public T identity(@GraphQLArgument(name = "input") T input) {
    return input;
}
 
Example #27
Source File: Street.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery(name = "name", description = "Street name")
public @GraphQLNonNull String getName() {
    return name;
}
 
Example #28
Source File: InputFieldDiscoveryTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLQuery(name = "ccc")
public Object getField3() {
    return field3;
}
 
Example #29
Source File: PolymorphicJsonTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@Override
@GraphQLQuery(name = "item")
public String getItem() {
    return item + getClass().getSimpleName();
}
 
Example #30
Source File: ResolverBuilderTest.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@GraphQLIgnore
@GraphQLQuery(name = "ignoredToo")
public <T> T wouldBreak() { return null; }