Skip to content

Commit

Permalink
Merge pull request #493 from griffithlab/civicpy
Browse files Browse the repository at this point in the history
New endpoint for all genes (required for CIViCpy)
  • Loading branch information
susannasiebert authored Apr 26, 2022
2 parents 364cfbf + 1b53623 commit a98e499
Show file tree
Hide file tree
Showing 5 changed files with 302 additions and 4 deletions.
70 changes: 70 additions & 0 deletions client/src/app/generated/server.model.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2834,6 +2834,51 @@ type Gene implements Commentable & EventSubject & Flaggable & WithRevisions {
): VariantConnection!
}

"""
The connection type for Gene.
"""
type GeneConnection {
"""
A list of edges.
"""
edges: [GeneEdge!]!

"""
A list of nodes.
"""
nodes: [Gene!]!

"""
Total number of pages, based on filtered count and pagesize.
"""
pageCount: Int!

"""
Information to aid in pagination.
"""
pageInfo: PageInfo!

"""
The total number of records in this filtered collection.
"""
totalCount: Int!
}

"""
An edge in a connection.
"""
type GeneEdge {
"""
A cursor for use in pagination.
"""
cursor: String!

"""
The item at the end of the edge.
"""
node: Gene
}

"""
Fields on a Gene that curators may propose revisions to.
"""
Expand Down Expand Up @@ -4546,6 +4591,31 @@ type Query {
"""
geneTypeahead(queryTerm: String!): [Gene!]!

"""
List and filter genes.
"""
genes(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String

"""
Returns the elements in the list that come before the specified cursor.
"""
before: String

"""
Returns the first _n_ elements from the list.
"""
first: Int

"""
Returns the last _n_ elements from the list.
"""
last: Int
): GeneConnection!

"""
Retrieve NCCN Guideline options as a typeahead
"""
Expand Down
211 changes: 211 additions & 0 deletions client/src/app/generated/server.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13065,6 +13065,152 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "GeneConnection",
"description": "The connection type for Gene.",
"fields": [
{
"name": "edges",
"description": "A list of edges.",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "GeneEdge",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "nodes",
"description": "A list of nodes.",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Gene",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "pageCount",
"description": "Total number of pages, based on filtered count and pagesize.",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "pageInfo",
"description": "Information to aid in pagination.",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "PageInfo",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "totalCount",
"description": "The total number of records in this filtered collection.",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "GeneEdge",
"description": "An edge in a connection.",
"fields": [
{
"name": "cursor",
"description": "A cursor for use in pagination.",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "node",
"description": "The item at the end of the edge.",
"args": [],
"type": {
"kind": "OBJECT",
"name": "Gene",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "GeneFields",
Expand Down Expand Up @@ -20219,6 +20365,71 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "genes",
"description": "List and filter genes.",
"args": [
{
"name": "after",
"description": "Returns the elements in the list that come after the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "before",
"description": "Returns the elements in the list that come before the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "first",
"description": "Returns the first _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "last",
"description": "Returns the last _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "GeneConnection",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "nccnGuidelinesTypeahead",
"description": "Retrieve NCCN Guideline options as a typeahead",
Expand Down
11 changes: 11 additions & 0 deletions server/app/graphql/resolvers/top_level_genes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'search_object/plugin/graphql'

class Resolvers::TopLevelGenes < GraphQL::Schema::Resolver
include SearchObject.module(:graphql)

type Types::Entities::GeneType.connection_type, null: false

description 'List and filter genes.'

scope { Gene.joins(variants: [:evidence_items]).order('genes.name ASC').where("evidence_items.status != 'rejected'").distinct }
end
12 changes: 9 additions & 3 deletions server/app/graphql/types/entities/variant_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,21 @@ def evidence_score
end

def variant_aliases
object.variant_aliases.map{|a| a.name}
Loaders::AssociationLoader.for(Variant, :variant_aliases).load(object).then do |va|
va.map(&:name)
end
end

def clinvar_ids
object.clinvar_entries.map{|e| e.clinvar_id}
Loaders::AssociationLoader.for(Variant, :clinvar_entries).load(object).then do |clinvar_entries|
clinvar_entries.map(&:clinvar_id)
end
end

def hgvs_descriptions
object.hgvs_expressions.map{|e| e.expression}
Loaders::AssociationLoader.for(Variant, :hgvs_expressions).load(object).then do |hgvs|
hgvs.map(&:expression)
end
end

def my_variant_info
Expand Down
2 changes: 1 addition & 1 deletion server/app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def authorized?(object, args, context)
argument :comment_text, String, required: true
end


field :genes, resolver: Resolvers::TopLevelGenes
field :variants, resolver: Resolvers::TopLevelVariants, max_page_size: 50

field :evidence_items, resolver: Resolvers::TopLevelEvidenceItems
Expand Down

0 comments on commit a98e499

Please sign in to comment.