Skip to content

Commit

Permalink
fix: root query has the over 100 fields warning
Browse files Browse the repository at this point in the history
  • Loading branch information
haifeng-li-at-salesforce committed Sep 30, 2024
1 parent 333e268 commit c60e558
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 349 deletions.
13 changes: 10 additions & 3 deletions src/rules/graphql/no-more-than-100-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { GraphQLESLintRule, GraphQLESLintRuleContext } from '@graphql-eslint/esl
import {
getClosestAncestorByType,
getEntityNodeForEdges,
getPageSizeFromEntityNode
getPageSizeFromEntityNode,
getParentEntityNode
} from '../../util/graphql-ast-utils';

export const NO_MORE_THAN_100_FIELDS_RULE_ID = 'offline-graphql-no-more-than-100-fields';
Expand Down Expand Up @@ -371,7 +372,7 @@ export const rule: GraphQLESLintRule = {
},
messages: {
[NO_MORE_THAN_100_FIELDS_RULE_ID]:
'Offline GraphQL: The "{{entityName}}" entity query contains {{numberOfFields}} fields and requests {{numberOfRecords}} records. If an entity query has more than 100 fields and requests over 200 records, the query will be capped to 200 records'
'Offline GraphQL: The root "{{entityName}}" entity query contains {{numberOfFields}} fields and requests {{numberOfRecords}} records. If a root entity query has more than 100 fields and requests over 200 records, the query will be capped to 200 records'
},
schema: []
},
Expand All @@ -396,8 +397,14 @@ export const rule: GraphQLESLintRule = {

const entityNode = getEntityNodeForEdges(edgeNode);
if (entityNode !== undefined) {
const isRootQuery = getParentEntityNode(entityNode) === undefined;
const pageSize = getPageSizeFromEntityNode(entityNode);
if (pageSize > MAX_SOQL_API_SERVER_ALLOWD_RECORD_NUMBER) {

// Root query has m
if (
isRootQuery &&
pageSize > MAX_SOQL_API_SERVER_ALLOWD_RECORD_NUMBER
) {
context.report({
messageId: NO_MORE_THAN_100_FIELDS_RULE_ID,
node: entityNode.name,
Expand Down
Loading

0 comments on commit c60e558

Please sign in to comment.