2929public class Relay {
3030
3131 public static final String NODE = "Node" ;
32+
3233 private GraphQLObjectType pageInfoType = newObject ()
3334 .name ("PageInfo" )
3435 .description ("Information about pagination in a connection." )
@@ -51,7 +52,7 @@ public class Relay {
5152 .build ();
5253
5354 public GraphQLInterfaceType nodeInterface (TypeResolver typeResolver ) {
54- GraphQLInterfaceType node = newInterface ()
55+ return newInterface ()
5556 .name (NODE )
5657 .description ("An object with an ID" )
5758 .typeResolver (typeResolver )
@@ -60,11 +61,10 @@ public GraphQLInterfaceType nodeInterface(TypeResolver typeResolver) {
6061 .description ("The ID of an object" )
6162 .type (new GraphQLNonNull (GraphQLID )))
6263 .build ();
63- return node ;
6464 }
6565
6666 public GraphQLFieldDefinition nodeField (GraphQLInterfaceType nodeInterface , DataFetcher nodeDataFetcher ) {
67- GraphQLFieldDefinition fieldDefinition = newFieldDefinition ()
67+ return newFieldDefinition ()
6868 .name ("node" )
6969 .description ("Fetches an object given its ID" )
7070 .type (nodeInterface )
@@ -74,91 +74,93 @@ public GraphQLFieldDefinition nodeField(GraphQLInterfaceType nodeInterface, Data
7474 .description ("The ID of an object" )
7575 .type (new GraphQLNonNull (GraphQLID )))
7676 .build ();
77- return fieldDefinition ;
7877 }
7978
8079 public List <GraphQLArgument > getConnectionFieldArguments () {
8180 List <GraphQLArgument > args = new ArrayList <>();
82-
8381 args .add (newArgument ()
8482 .name ("before" )
83+ .description ("fetching only nodes before this node (exclusive)" )
8584 .type (GraphQLString )
8685 .build ());
8786 args .add (newArgument ()
8887 .name ("after" )
88+ .description ("fetching only nodes after this node (exclusive)" )
8989 .type (GraphQLString )
9090 .build ());
9191 args .add (newArgument ()
9292 .name ("first" )
93+ .description ("fetching only the first certain number of nodes" )
9394 .type (GraphQLInt )
9495 .build ());
9596 args .add (newArgument ()
9697 .name ("last" )
98+ .description ("fetching only the last certain number of nodes" )
9799 .type (GraphQLInt )
98100 .build ());
99101 return args ;
100102 }
101103
102104 public List <GraphQLArgument > getBackwardPaginationConnectionFieldArguments () {
103105 List <GraphQLArgument > args = new ArrayList <>();
104-
105106 args .add (newArgument ()
106107 .name ("before" )
108+ .description ("fetching only nodes before this node (exclusive)" )
107109 .type (GraphQLString )
108110 .build ());
109111 args .add (newArgument ()
110112 .name ("last" )
113+ .description ("fetching only the last certain number of nodes" )
111114 .type (GraphQLInt )
112115 .build ());
113116 return args ;
114117 }
115118
116119 public List <GraphQLArgument > getForwardPaginationConnectionFieldArguments () {
117120 List <GraphQLArgument > args = new ArrayList <>();
118-
119121 args .add (newArgument ()
120122 .name ("after" )
123+ .description ("fetching only nodes after this node (exclusive)" )
121124 .type (GraphQLString )
122125 .build ());
123126 args .add (newArgument ()
124127 .name ("first" )
128+ .description ("fetching only the first certain number of nodes" )
125129 .type (GraphQLInt )
126130 .build ());
127131 return args ;
128132 }
129133
130134 public GraphQLObjectType edgeType (String name , GraphQLOutputType nodeType , GraphQLInterfaceType nodeInterface , List <GraphQLFieldDefinition > edgeFields ) {
131-
132- GraphQLObjectType edgeType = newObject ()
135+ return newObject ()
133136 .name (name + "Edge" )
134- .description ("An edge in a connection. " )
137+ .description ("An edge in a connection" )
135138 .field (newFieldDefinition ()
136139 .name ("node" )
137140 .type (nodeType )
138141 .description ("The item at the end of the edge" ))
139142 .field (newFieldDefinition ()
140143 .name ("cursor" )
141144 .type (new GraphQLNonNull (GraphQLString ))
142- .description ("" ))
145+ .description ("cursor marks a unique position or index into the connection " ))
143146 .fields (edgeFields )
144147 .build ();
145- return edgeType ;
146148 }
147149
148150 public GraphQLObjectType connectionType (String name , GraphQLObjectType edgeType , List <GraphQLFieldDefinition > connectionFields ) {
149-
150- GraphQLObjectType connectionType = newObject ()
151+ return newObject ()
151152 .name (name + "Connection" )
152153 .description ("A connection to a list of items." )
153154 .field (newFieldDefinition ()
154155 .name ("edges" )
156+ .description ("a list of edges" )
155157 .type (new GraphQLList (edgeType )))
156158 .field (newFieldDefinition ()
157159 .name ("pageInfo" )
160+ .description ("details about this specific page" )
158161 .type (new GraphQLNonNull (pageInfoType )))
159162 .fields (connectionFields )
160163 .build ();
161- return connectionType ;
162164 }
163165
164166
0 commit comments