diff --git a/client/src/app/generated/server.model.graphql b/client/src/app/generated/server.model.graphql index 683d7a0a9..0f25c03e9 100644 --- a/client/src/app/generated/server.model.graphql +++ b/client/src/app/generated/server.model.graphql @@ -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. """ @@ -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 """ diff --git a/client/src/app/generated/server.schema.json b/client/src/app/generated/server.schema.json index d0f69694e..62ddbb4d4 100644 --- a/client/src/app/generated/server.schema.json +++ b/client/src/app/generated/server.schema.json @@ -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", @@ -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", diff --git a/server/app/graphql/resolvers/top_level_genes.rb b/server/app/graphql/resolvers/top_level_genes.rb new file mode 100644 index 000000000..7a6f71c70 --- /dev/null +++ b/server/app/graphql/resolvers/top_level_genes.rb @@ -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 diff --git a/server/app/graphql/types/entities/variant_type.rb b/server/app/graphql/types/entities/variant_type.rb index f8838f215..03642e03c 100644 --- a/server/app/graphql/types/entities/variant_type.rb +++ b/server/app/graphql/types/entities/variant_type.rb @@ -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 diff --git a/server/app/graphql/types/query_type.rb b/server/app/graphql/types/query_type.rb index 3b5cdacf8..b08f886b8 100644 --- a/server/app/graphql/types/query_type.rb +++ b/server/app/graphql/types/query_type.rb @@ -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