@@ -78,6 +78,8 @@ import { TypeWeightObject, Variables } from '../../src/@types/buildTypeWeights';
7878 stars: Int!
7979 commentary: String
8080 }
81+
82+
8183
8284 *
8385 * TODO: extend this schema to include mutations, subscriptions and pagination
@@ -86,7 +88,8 @@ import { TypeWeightObject, Variables } from '../../src/@types/buildTypeWeights';
8688 type Subscription {
8789 reviewAdded(episode: Episode): Review
8890 }
89- type FriendsConnection {
91+
92+ type FriendsConnection {
9093 totalCount: Int
9194 edges: [FriendsEdge]
9295 friends: [Character]
@@ -918,6 +921,9 @@ describe('Test getQueryTypeComplexity function', () => {
918921 expect ( getQueryTypeComplexity ( parse ( query ) , variables , typeWeights ) ) . toBe ( 5 ) ; // 1 Query + 4 search results
919922 } ) ;
920923
924+ // TODO: create tests for an implementation of the connection pagination convention -- need soln for unbounded lists
925+ xdescribe ( 'connection pagination convention' , ( ) => { } ) ;
926+
921927 // TODO: directives @skip , @include and custom directives
922928 } ) ;
923929
@@ -933,6 +939,32 @@ describe('Test getQueryTypeComplexity function', () => {
933939 }` ;
934940 expect ( getQueryTypeComplexity ( parse ( query ) , variables , typeWeights ) ) . toBe ( 11 ) ; // Mutation 10 + review 1
935941 } ) ;
942+
943+ test ( 'mutation with no feilds queried' , ( ) => {
944+ variables = { review : { stars : 5 , commentary : 'good' } } ;
945+ query = `mutation createReviewMutation($review: ReviewInput!) {
946+ createReview(episode: Empire, review: $review)
947+ }` ;
948+ expect ( getQueryTypeComplexity ( parse ( query ) , variables , typeWeights ) ) . toBe ( 11 ) ; // Mutation 10 + review 1
949+ } ) ;
950+
951+ test ( 'mutation and query definitons' , ( ) => {
952+ variables = { review : { stars : 5 , commentary : 'good' } } ;
953+ query = `mutation createReviewMutation($review: ReviewInput!) {
954+ createReview(episode: Empire, review: $review) {
955+ stars
956+ commentary
957+ episode
958+ }
959+ }
960+
961+ query {
962+ hero(episode: EMPIRE) {
963+ name
964+ }
965+ }` ;
966+ expect ( getQueryTypeComplexity ( parse ( query ) , variables , typeWeights ) ) . toBe ( 13 ) ; // Mutation 10 + review 1 + query 1 + character 1
967+ } ) ;
936968 } ) ;
937969
938970 xdescribe ( 'Calculates the correct type complexity for subscriptions' , ( ) => { } ) ;
0 commit comments