Skip to content

Commit e9cd799

Browse files
committed
Improve documentation for types
1 parent 7c82570 commit e9cd799

16 files changed

+665
-88
lines changed

lib/schema.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function newTempusSchema(tempus) {
4747
fields: () => ({
4848
map: {
4949
type: MapType,
50+
description: "Get a single jump map by name or ID",
5051
args: {
5152
name: { type: GraphQLString },
5253
id: { type: GraphQLInt },
@@ -55,6 +56,8 @@ function newTempusSchema(tempus) {
5556
},
5657
maps: {
5758
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(MapType))),
59+
description:
60+
"Get a list of jump maps, with an optional search parameter",
5861
args: {
5962
search: { type: GraphQLString },
6063
start: { type: GraphQLInt },
@@ -71,27 +74,31 @@ function newTempusSchema(tempus) {
7174
},
7275
player: {
7376
type: PlayerType,
77+
description: "Get a player by ID",
7478
args: {
7579
id: { type: new GraphQLNonNull(GraphQLInt) },
7680
},
7781
resolve: (root, args) => new Player(context, args),
7882
},
7983
record: {
8084
type: RecordType,
85+
description: "Get a record by ID",
8186
args: {
8287
id: { type: new GraphQLNonNull(GraphQLInt) },
8388
},
8489
resolve: (root, args) => new Record(context, args),
8590
},
8691
demo: {
8792
type: DemoType,
93+
description: "Get a demo recording by ID",
8894
args: {
8995
id: { type: new GraphQLNonNull(GraphQLInt) },
9096
},
9197
resolve: (root, args) => new Demo(context, args),
9298
},
9399
server: {
94100
type: ServerType,
101+
description: "Get a server by ID",
95102
args: {
96103
id: { type: new GraphQLNonNull(GraphQLInt) },
97104
},
@@ -101,6 +108,7 @@ function newTempusSchema(tempus) {
101108
type: new GraphQLNonNull(
102109
new GraphQLList(new GraphQLNonNull(ServerType))
103110
),
111+
description: "Get a list of servers, with an optional search parameter",
104112
args: {
105113
search: { type: GraphQLString },
106114
start: { type: GraphQLInt },
@@ -118,13 +126,16 @@ function newTempusSchema(tempus) {
118126
},
119127
},
120128
activity: {
129+
description: "Get the recent activity on the Tempus network",
121130
type: new GraphQLNonNull(ActivityType),
122131
resolve: () => new Activity(context),
123132
},
124133
players: {
125134
type: new GraphQLNonNull(
126135
new GraphQLList(new GraphQLNonNull(PlayerType))
127136
),
137+
description:
138+
"Get a list of players, with an optional search parameter, in descending order by overall rank",
128139
args: {
129140
search: { type: GraphQLString },
130141
start: { type: GraphQLInt },
@@ -139,6 +150,7 @@ function newTempusSchema(tempus) {
139150
},
140151
rankings: {
141152
type: new GraphQLNonNull(RankingListingType),
153+
description: "Get the soldier, demoman, or overall tempus rankings",
142154
args: {
143155
start: { type: GraphQLInt },
144156
type: { type: new GraphQLNonNull(RankingTypeEnum) },

lib/types/activity.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,31 @@ export default new GraphQLObjectType({
1212
fields: () => ({
1313
bonusWrs: {
1414
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(RecordType))),
15+
description: "The recent bonus world records",
1516
args: {
1617
start: { type: GraphQLInt },
1718
limit: { type: GraphQLInt },
1819
},
1920
},
2021
courseWrs: {
2122
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(RecordType))),
23+
description: "The recent course world records",
2224
args: {
2325
start: { type: GraphQLInt },
2426
limit: { type: GraphQLInt },
2527
},
2628
},
2729
mapWrs: {
2830
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(RecordType))),
31+
description: "The recent map world records",
2932
args: {
3033
start: { type: GraphQLInt },
3134
limit: { type: GraphQLInt },
3235
},
3336
},
3437
mapTops: {
3538
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(RecordType))),
39+
description: "The recent map top times",
3640
args: {
3741
start: { type: GraphQLInt },
3842
limit: { type: GraphQLInt },

lib/types/class_type_enum.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { GraphQLEnumType } from "graphql";
22

33
export default new GraphQLEnumType({
44
name: "Class",
5+
description:
6+
"The class, either soldier or demoman. Demoman is often abbreviated as 'demo', which is different from a demo recording",
57
values: {
68
SOLDIER: { value: "soldier" },
79
DEMOMAN: { value: "demoman" },

lib/types/demo.js

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,50 @@ import ServerType from "./server";
1212

1313
export default new GraphQLObjectType({
1414
name: "Demo",
15+
description:
16+
"A demo recording. Contains information about a particular server recording. Not the same as the abbreviation for demoman",
1517

1618
fields: () => ({
17-
id: { type: new GraphQLNonNull(GraphQLInt) },
18-
map: { type: new GraphQLNonNull(MapType) },
19-
filename: { type: GraphQLString },
20-
date: { type: new GraphQLNonNull(GraphQLFloat) },
21-
url: { type: GraphQLString },
22-
recording: { type: new GraphQLNonNull(GraphQLBoolean) },
23-
requested: { type: new GraphQLNonNull(GraphQLBoolean) },
24-
expired: { type: new GraphQLNonNull(GraphQLBoolean) },
25-
deleted: { type: new GraphQLNonNull(GraphQLBoolean) },
26-
uploader: { type: PlayerType },
27-
server: { type: new GraphQLNonNull(ServerType) },
19+
id: {
20+
type: new GraphQLNonNull(GraphQLInt),
21+
description: "The ID of this demo",
22+
},
23+
map: {
24+
type: new GraphQLNonNull(MapType),
25+
description: "The map for this demo",
26+
},
27+
filename: { type: GraphQLString, description: "The filename of this demo" },
28+
date: {
29+
type: new GraphQLNonNull(GraphQLFloat),
30+
description: "The date of this demo in unix seconds",
31+
},
32+
url: {
33+
type: GraphQLString,
34+
description: "The URL for downloading this demo, if available",
35+
},
36+
recording: {
37+
type: new GraphQLNonNull(GraphQLBoolean),
38+
description: "If this demo is currently recording",
39+
},
40+
requested: {
41+
type: new GraphQLNonNull(GraphQLBoolean),
42+
description: "If an upload of this demo has been requested",
43+
},
44+
expired: {
45+
type: new GraphQLNonNull(GraphQLBoolean),
46+
description: "If the upload of this demo has expired",
47+
},
48+
deleted: {
49+
type: new GraphQLNonNull(GraphQLBoolean),
50+
description: "If the upload of this demo has been deleted",
51+
},
52+
uploader: {
53+
type: PlayerType,
54+
description: "The player who uploaded this demo",
55+
},
56+
server: {
57+
type: new GraphQLNonNull(ServerType),
58+
description: "The server where this demo was recorded",
59+
},
2860
}),
2961
});

lib/types/map.js

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,44 @@ import ClassTypeEnum from "./class_type_enum";
1414

1515
const Author = new GraphQLObjectType({
1616
name: "Author",
17+
description: "An author of a map",
1718

1819
fields: () => ({
19-
id: { type: new GraphQLNonNull(GraphQLInt) },
20-
name: { type: new GraphQLNonNull(GraphQLString) },
20+
id: {
21+
type: new GraphQLNonNull(GraphQLInt),
22+
description: "The ID of the author",
23+
},
24+
name: {
25+
type: new GraphQLNonNull(GraphQLString),
26+
description: "The name of the author",
27+
},
2128
mapCount: {
2229
type: new GraphQLNonNull(GraphQLInt),
30+
description: "The number of maps this author has created",
2331
resolve: (author) => author.map_count,
2432
},
25-
player: { type: PlayerType },
33+
player: {
34+
type: PlayerType,
35+
description:
36+
"The author's Player, if the author is a registered Tempus player",
37+
},
2638
}),
2739
});
2840

2941
const MapVideos = new GraphQLObjectType({
3042
name: "MapVideos",
43+
description: "The videos with playthroughs of a map",
3144

3245
fields: () => ({
3346
soldier: {
3447
type: GraphQLString,
48+
description: "The URL for the video of a soldier playthrough of a map",
3549
resolve: (videos) =>
3650
videos.soldier && `https://youtube.com/watch?v=${videos.soldier}`,
3751
},
3852
demoman: {
3953
type: GraphQLString,
54+
description: "The URL for the video of a demoman playthrough of a map",
4055
resolve: (videos) =>
4156
videos.demoman && `https://youtube.com/watch?v=${videos.demoman}`,
4257
},
@@ -45,37 +60,48 @@ const MapVideos = new GraphQLObjectType({
4560

4661
const Zones = new GraphQLObjectType({
4762
name: "Zones",
63+
description: "The zones for a map",
4864

4965
fields: () => ({
5066
bonus: {
5167
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ZoneType))),
68+
description: "The bonus zones for a map",
5269
},
5370
bonusEnd: {
5471
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ZoneType))),
72+
description: "The bonus end zones for a map",
5573
},
5674
checkpoint: {
5775
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ZoneType))),
76+
description: "The checkpoint zones for a map",
5877
},
5978
course: {
6079
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ZoneType))),
80+
description: "The course zones for a map",
6181
},
6282
courseEnd: {
6383
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ZoneType))),
84+
description: "The course end zones for a map",
6485
},
6586
linear: {
6687
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ZoneType))),
88+
description: "The linear zones for a map",
6789
},
6890
map: {
6991
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ZoneType))),
92+
description: "The map zones for a map",
7093
},
7194
mapEnd: {
7295
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ZoneType))),
96+
description: "The end zones for a map",
7397
},
7498
misc: {
7599
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ZoneType))),
100+
description: "The miscellaneous zones for a map",
76101
},
77102
trick: {
78103
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ZoneType))),
104+
description: "The trick zones for a map",
79105
},
80106
}),
81107
});
@@ -85,16 +111,34 @@ export default new GraphQLObjectType({
85111
description: "A jump map",
86112

87113
fields: () => ({
88-
id: { type: new GraphQLNonNull(GraphQLString) },
89-
name: { type: new GraphQLNonNull(GraphQLString) },
114+
id: {
115+
type: new GraphQLNonNull(GraphQLString),
116+
description: "The ID of the map",
117+
},
118+
name: {
119+
type: new GraphQLNonNull(GraphQLString),
120+
description: "The name of the map",
121+
},
90122
authors: {
91123
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(Author))),
124+
description: "The authors of this map",
125+
},
126+
videos: {
127+
type: new GraphQLNonNull(MapVideos),
128+
description: "Videos showing playthroughs of this map",
129+
},
130+
tiers: {
131+
type: new GraphQLNonNull(Tiers),
132+
description: "The tiers of this map",
133+
},
134+
zones: {
135+
type: new GraphQLNonNull(Zones),
136+
description: "The zones of this map",
92137
},
93-
videos: { type: new GraphQLNonNull(MapVideos) },
94-
tiers: { type: new GraphQLNonNull(Tiers) },
95-
zones: { type: new GraphQLNonNull(Zones) },
96138
records: {
97139
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(RecordType))),
140+
description:
141+
"Player records on this map, filterable by class and zone. Later records can be fetched with a non-empty start argument",
98142
args: {
99143
zoneType: { type: ZoneTypeEnum },
100144
zoneId: { type: GraphQLInt },
@@ -105,6 +149,8 @@ export default new GraphQLObjectType({
105149
},
106150
record: {
107151
type: RecordType,
152+
description:
153+
"Fetch a single record on this map by providing the player and class, and optionally a zone. Without a zone, the player's map record will be fetched",
108154
args: {
109155
zoneType: { type: ZoneTypeEnum },
110156
zoneId: { type: GraphQLInt },
@@ -114,6 +160,7 @@ export default new GraphQLObjectType({
114160
},
115161
wr: {
116162
type: RecordType,
163+
description: "Fetch the world record on this map by class",
117164
args: {
118165
class: { type: new GraphQLNonNull(ClassTypeEnum) },
119166
},

0 commit comments

Comments
 (0)