GraphQL: Check that connections support keyset pagination
What does this MR do?
When a GraphQL type, such as Types::ProjectType
uses a field as a connection type (which uses our underlying keyset/cursor pagination), we want to ensure that the type has been tested that it supports the pagination
module Types
class ProjectType < BaseObject
field :issues, # rubocop:disable Graphql/Descriptions
Types::IssueType.connection_type,
null: true,
resolver: Resolvers::IssuesResolver
end
end
We need to make sure that Types::IssueType
has been properly tested with the pagination.
This MR implements one proposal. An overall spec was written in gitlab_schema_spec.rb
that iterates over the schema, detects connection fields, and checks a flag on the type that indicates it supports pagination. For example, by adding
# means specs written/pass for using this type as a paginated connection
supports_keyset_pagination
to the Types::IssueType
, that indicates that we've tested this type with keyset pagination.
Of course, this is manual - a developer must write the specs and add the supports_keyset_pagination
, and of course it could be added without the actual specs. So it's far from perfect or automated. But the comment should stay with the line to highlight it when someone copy/pastes the code.
Very much open to a better way to solve this.
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation created/updated or follow-up review issue created -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team