Skip to content

Commit 6b608c2

Browse files
committed
coverage
1 parent c3cc9e4 commit 6b608c2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

spec/GraphQLQueryComplexity.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,29 @@ describe('graphql query complexity', () => {
147147
);
148148
});
149149

150+
it('should count inline fragment fields toward depth and field limits', async () => {
151+
await setupGraphQL({
152+
requestComplexity: { graphQLFields: 3 },
153+
});
154+
// Inline fragment adds fields without increasing depth:
155+
// users(1) > edges(2) > ... on UserConnection { edges(3) > node(4) }
156+
const result = await graphqlRequest(`{
157+
users {
158+
edges {
159+
... on UserEdge {
160+
node {
161+
objectId
162+
}
163+
}
164+
}
165+
}
166+
}`);
167+
expect(result.errors).toBeDefined();
168+
expect(result.errors[0].message).toMatch(
169+
/Number of GraphQL fields \(\d+\) exceeds maximum allowed \(3\)/
170+
);
171+
});
172+
150173
it('should allow unlimited fields when graphQLFields is -1', async () => {
151174
await setupGraphQL({
152175
requestComplexity: { graphQLFields: -1 },

0 commit comments

Comments
 (0)