Skip to content

Commit dbb436c

Browse files
committed
started to layout connection pagination convention in buildTypeWeights tests
1 parent 96bd463 commit dbb436c

File tree

2 files changed

+64
-42
lines changed

2 files changed

+64
-42
lines changed

test/analysis/buildTypeWeights.test.ts

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,60 @@ describe('Test buildTypeWeightsFromSchema function', () => {
305305
});
306306
});
307307

308+
// FIXME: what would we expect here?
309+
xtest('connections paginiton convention', () => {
310+
schema = buildSchema(`
311+
type Query {
312+
hero(id: ID): Character
313+
}
314+
type Character {
315+
id: ID!
316+
name: String!
317+
friends(first:Int after: String): [FriendsConnection]
318+
}
319+
type FriendsConnection {
320+
totalCount: Int
321+
edges: [FriendsEdge]
322+
friends: [Character]
323+
pageInfo: PageInfo!
324+
}
325+
type FriendsEdge {
326+
cursor: ID!
327+
node: Character
328+
}
329+
type PageInfo {
330+
startCursor: ID
331+
endCursor: ID
332+
hasNextPage: Boolean!
333+
}
334+
`);
335+
expect(buildTypeWeightsFromSchema(schema)).toEqual({
336+
query: {
337+
weight: 1,
338+
fields: {
339+
hero: { resolveTo: 'character' },
340+
},
341+
},
342+
character: {
343+
weight: 1,
344+
fields: {
345+
id: { weight: 0 },
346+
name: { weight: 0 },
347+
friends: { resolveTo: 'friendsConnection' },
348+
},
349+
},
350+
friendsConnection: {
351+
weight: 2,
352+
fields: {
353+
totalCount: { weight: 0 },
354+
// edges: {resolveTo: }
355+
},
356+
},
357+
friendsEdge: {},
358+
pageInfo: {},
359+
});
360+
});
361+
308362
describe('mutation types...', () => {
309363
test('a mutation type and a query type', () => {
310364
schema = buildSchema(`
@@ -370,45 +424,6 @@ describe('Test buildTypeWeightsFromSchema function', () => {
370424
},
371425
});
372426
});
373-
374-
// ?mutation and an output type
375-
xtest('a mutation type and a query type', () => {
376-
schema = buildSchema(`
377-
type Mutation {
378-
login(user: UserInput!): User
379-
}
380-
type User{
381-
id: ID!
382-
email: String!
383-
password: String!
384-
}
385-
input UserInput {
386-
email: String!
387-
password: String!
388-
}
389-
`);
390-
391-
expect(buildTypeWeightsFromSchema(schema)).toEqual({
392-
mutation: {
393-
weight: 10,
394-
fields: {
395-
name: { weight: 0 },
396-
email: { weight: 0 },
397-
},
398-
},
399-
user: {
400-
weight: 1,
401-
fields: {
402-
id: { weight: 0 },
403-
email: { weight: 0 },
404-
password: { weight: 0 },
405-
},
406-
},
407-
});
408-
});
409-
// mutations with lists
410-
411-
// mutations with nonNull
412427
});
413428

414429
describe('fields returning lists of objects of determinate size and...', () => {

test/analysis/typeComplexityAnalysis.test.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,19 @@ import { TypeWeightObject, Variables } from '../../src/@types/buildTypeWeights';
7070
scalars: Scalars
7171
}
7272
73-
*
74-
* TODO: extend this schema to include mutations, subscriptions and pagination
75-
*
7673
type Mutation {
7774
createReview(episode: Episode, review: ReviewInput!): Review
7875
}
76+
77+
input ReviewInput {
78+
stars: Int!
79+
commentary: String
80+
}
81+
82+
*
83+
* TODO: extend this schema to include mutations, subscriptions and pagination
84+
*
85+
7986
type Subscription {
8087
reviewAdded(episode: Episode): Review
8188
}

0 commit comments

Comments
 (0)