-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.bal
More file actions
94 lines (74 loc) · 2.17 KB
/
main.bal
File metadata and controls
94 lines (74 loc) · 2.17 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import ballerina/graphql;
import ballerina/http;
public enum Scope {
USER,
FRIEND,
OTHER
}
@graphql:ServiceConfig {
interceptors: [new AccessGrant()],
contextInit:
isolated function(http:RequestContext requestContext, http:Request request) returns graphql:Context|error {
graphql:Context context = new;
context.set("scope", check request.getHeader("scope"));
return context;
},
graphiql: {
enable: true
}
}
isolated service /graphql on new graphql:Listener(9000) {
isolated resource function get profile() returns Profile {
return new;
}
}
public isolated service class Profile {
isolated resource function get name() returns string {
return "dimuthu";
}
isolated resource function get profilePic() returns string {
return "link1";
}
isolated resource function get bio() returns string {
return "Student";
}
isolated resource function get mobile() returns string? {
return "+940111348734";
}
isolated resource function get birthday/day() returns int? {
return 5;
}
isolated resource function get birthday/month() returns string? {
return "Octomber";
}
isolated resource function get birthday/year() returns int? {
return 1995;
}
isolated resource function get address/street() returns string? {
return "Main Street";
}
isolated resource function get address/homeTown() returns string? {
return "Deniyaya";
}
isolated resource function get address/currentCity() returns string {
return "Matara";
}
isolated resource function get posts/owner() returns Profile {
return new;
}
isolated resource function get posts/likes() returns int {
return 345;
}
isolated resource function get posts/shares() returns int {
return 4;
}
isolated resource function get posts/date/day() returns int? {
return 3;
}
isolated resource function get posts/date/month() returns string? {
return "August";
}
isolated resource function get posts/date/year() returns int? {
return 2022;
}
}