-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathUser.java
More file actions
47 lines (35 loc) · 1.1 KB
/
Copy pathUser.java
File metadata and controls
47 lines (35 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package graphql;
import graphql.annotations.GraphQLDataFetcher;
import graphql.annotations.GraphQLField;
import graphql.annotations.GraphQLType;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import java.util.ArrayList;
import java.util.List;
@GraphQLType
public class User {
public static class TestFetcher implements DataFetcher {
@Override
public List<Story> get(DataFetchingEnvironment environment) {
User parent = (User) environment.getSource();
Story firstStory = new Story("Oded Story", parent);
Story secondStory = new Story("Good Story", parent);
List<Story> stories = new ArrayList<Story>() {{ add(firstStory); add(secondStory);}};
return stories;
}
}
@GraphQLField
public String name() {
return this.getName();
}
@GraphQLField
@GraphQLDataFetcher(TestFetcher.class)
public List<Story> stories;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}