Skip to content

chore: add pagination and root field linter rules#112

Merged
ddebrunner merged 1 commit intomainfrom
lint-pagination
Jul 15, 2025
Merged

chore: add pagination and root field linter rules#112
ddebrunner merged 1 commit intomainfrom
lint-pagination

Conversation

@ddebrunner
Copy link
Contributor

Here's a PR description for the changes:


�� Add non-nullable first argument requirement to GraphQL pagination linting

Summary

Updated the GraphQL linter's pagination argument types rule to require Int! (non-nullable Int) for the first argument in pagination, enforcing better GraphQL API design patterns.

Changes Made

🔧 Core Linter Updates

  • Modified pagination-argument-types rule to specifically check for non-nullable Int type for first argument
  • Updated error message from 'first' argument should be of type 'Int' to 'first' argument should be of type 'Int!'
  • Enhanced type checking logic to distinguish between nullable and non-nullable types

�� Test Updates

  • Added new test case should detect nullable first argument type to verify nullable Int is flagged as error
  • Updated existing tests to use Int! instead of Int in valid examples
  • Updated test assertions to expect new error message format
  • Fixed test fixture copying in build process to resolve missing test files

📚 Documentation Updates

  • Updated documentation to reflect that first should be Int! instead of Int

Behavior Changes

Before:

type Query {
  users(first: Int, after: String): UserConnection!  # ✅ Allowed
}

After:

type Query {
  users(first: Int!, after: String): UserConnection!  # ✅ Valid
  users(first: Int, after: String): UserConnection!   # ❌ Error: should be 'Int!'
}

Testing

  • ✅ All 35 GraphQL linter tests passing
  • ✅ Updated pagination rules working correctly
  • ✅ Configuration changes handled properly
  • ✅ Error scenarios tested

Impact

This change enforces better GraphQL API design by requiring clients to always provide a limit value for pagination, preventing potential issues with undefined or null first arguments.


Jaffa Cakes earned: 5 🍰

@ddebrunner ddebrunner merged commit a85320c into main Jul 15, 2025
1 check passed
@ddebrunner ddebrunner deleted the lint-pagination branch July 15, 2025 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants