Skip to content

Commit

Permalink
Use safe access operator
Browse files Browse the repository at this point in the history
  • Loading branch information
susannasiebert authored Oct 16, 2024
1 parent 3c12ce2 commit 0ad002e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def gene(id: :unspecified, entrez_symbol: :unspecified)
raise GraphQL::ExecutionError.new('Must specify exactly one of id or entrezSymbol')
end
if (id != :unspecified)
Feature.find_by(feature_instance_type: 'Features::Gene', id: id).feature_instance
Feature.find_by(feature_instance_type: 'Features::Gene', id: id)&.feature_instance
else
Features::Gene.find_by(name: entrez_symbol)
end
Expand All @@ -234,14 +234,14 @@ def factor(id: :unspecified, ncit_id: :unspecified)
raise GraphQL::ExecutionError.new('Must specify exactly one of id or ncitId')
end
if (id != :unspecified)
Feature.find_by(feature_instance_type: 'Features::Factor', id: id).feature_instance
Feature.find_by(feature_instance_type: 'Features::Factor', id: id)&.feature_instance
else
Features::Factor.find_by(ncit_id: ncit_id)
end
end

def fusion(id: )
Feature.find_by(feature_instance_type: 'Features::Fusion', id: id).feature_instance
Feature.find_by(feature_instance_type: 'Features::Fusion', id: id)&.feature_instance
end

def feature(id: )
Expand Down

0 comments on commit 0ad002e

Please sign in to comment.