Skip to content

Expose `user` and `createdAt` in GraphQL `VersionType`

What does this MR do?

Expose user and createdAt in GraphQL VersionType

The GraphQL user field calls #lazy_user which loads the user record using the new User.lazy_find method.

.lazy_find has been written as a Concern in order for more models to use this.

Using BatchLoader to load associations in GraphQL avoids the normal n+1 problems.

This can be useful in GraphQL for all belongs_to.

This would normally execute a User SQL query per Version that was returned:

module Types
  class VersionType < BaseObject
    field :user, Types::UserType ...
  end
end

But a

module Types
  class VersionType < BaseObject
    field :user, Types::UserType ...

    def user
       # Batchloading logic
    end
  end
end

Executes just 1 (I'm guessing 1 among siblings in the AST).

Does this MR meet the acceptance criteria?

Conformity

Performance and Testing

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

Closes #13426 (closed)

Edited by 🤖 GitLab Bot 🤖

Merge request reports