Module: ResolvesProject

Included in:
Mutations::ResolvesResourceParent, Resolvers::Ci::ConfigResolver, Resolvers::UserMergeRequestsResolverBase
Defined in:
app/graphql/resolvers/concerns/resolves_project.rb

Instance Method Summary collapse

Instance Method Details

#resolve_project(full_path: nil, project_id: nil) ⇒ Object

Accepts EITHER one of

- full_path: String (see Project#full_path)
- project_id: GlobalID. Arguments should be typed as: `::Types::GlobalIDType[Project]`


7
8
9
10
11
12
13
14
15
16
17
# File 'app/graphql/resolvers/concerns/resolves_project.rb', line 7

def resolve_project(full_path: nil, project_id: nil)
  unless full_path.present? ^ project_id.present?
    raise ::Gitlab::Graphql::Errors::ArgumentError, 'Incompatible arguments: projectId, projectPath.'
  end

  if full_path.present?
    ::Gitlab::Graphql::Loaders::FullPathModelLoader.new(Project, full_path).find
  else
    ::GitlabSchema.object_from_id(project_id, expected_type: Project)
  end
end