@@ -6,8 +6,11 @@ import {
6
6
GraphQLSchema ,
7
7
GraphQLString ,
8
8
graphqlSync ,
9
+ printSchema ,
9
10
} from 'graphql' ;
10
11
12
+ import { dedent } from '../../__testUtils__/dedent' ;
13
+
11
14
import { connectionFromArray } from '../arrayConnection' ;
12
15
13
16
import {
@@ -176,4 +179,73 @@ describe('connectionDefinition()', () => {
176
179
} ,
177
180
} ) ;
178
181
} ) ;
182
+
183
+ it ( 'generates correct types' , ( ) => {
184
+ // FIXME remove trimEnd after we update to `[email protected] `
185
+ expect ( printSchema ( schema ) . trimEnd ( ) ) . to . deep . equal ( dedent `
186
+ type Query {
187
+ user: User
188
+ }
189
+
190
+ type User {
191
+ name: String
192
+ friends(after: String, first: Int, before: String, last: Int): FriendConnection
193
+ friendsForward(after: String, first: Int): UserConnection
194
+ friendsBackward(before: String, last: Int): UserConnection
195
+ }
196
+
197
+ """A connection to a list of items."""
198
+ type FriendConnection {
199
+ """Information to aid in pagination."""
200
+ pageInfo: PageInfo!
201
+
202
+ """A list of edges."""
203
+ edges: [FriendEdge]
204
+ totalCount: Int
205
+ }
206
+
207
+ """Information about pagination in a connection."""
208
+ type PageInfo {
209
+ """When paginating forwards, are there more items?"""
210
+ hasNextPage: Boolean!
211
+
212
+ """When paginating backwards, are there more items?"""
213
+ hasPreviousPage: Boolean!
214
+
215
+ """When paginating backwards, the cursor to continue."""
216
+ startCursor: String
217
+
218
+ """When paginating forwards, the cursor to continue."""
219
+ endCursor: String
220
+ }
221
+
222
+ """An edge in a connection."""
223
+ type FriendEdge {
224
+ """The item at the end of the edge"""
225
+ node: User
226
+
227
+ """A cursor for use in pagination"""
228
+ cursor: String!
229
+ friendshipTime: String
230
+ }
231
+
232
+ """A connection to a list of items."""
233
+ type UserConnection {
234
+ """Information to aid in pagination."""
235
+ pageInfo: PageInfo!
236
+
237
+ """A list of edges."""
238
+ edges: [UserEdge]
239
+ }
240
+
241
+ """An edge in a connection."""
242
+ type UserEdge {
243
+ """The item at the end of the edge"""
244
+ node: User
245
+
246
+ """A cursor for use in pagination"""
247
+ cursor: String!
248
+ }
249
+ ` ) ;
250
+ } ) ;
179
251
} ) ;
0 commit comments