Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix workflows query syntax and conditionally fire taxon/accession queries in sample report #314

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 41 additions & 23 deletions resolver-functions/SampleForReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ export const SampleForReportResolver = async (root, args, context)=> {
name
}
}
entityInputs(where: entityType { _in: ["taxon", "accession"] }) {
entityInputs(where: {entityType: {_in: ["taxon", "accession"]}}) {
edges {
node {
inputEntityId
entityType
inputEntityId
}
}
}
Expand All @@ -167,7 +167,7 @@ export const SampleForReportResolver = async (root, args, context)=> {
const workflowsWorkflowRuns: NextGenWorkflowsTypes.WorkflowRun[] = workflowsResp?.data?.workflowRuns || [];

// Fetch taxon info from entities based on workflow run inputs
const taxonEntityIds : { taxon: string[], accession: string [] } = {
const taxonEntityIds : { taxon: string[], accession: string[] } = {
taxon: [],
accession: [],
};
Expand All @@ -181,29 +181,47 @@ export const SampleForReportResolver = async (root, args, context)=> {
);
});

const taxaQuery = `
query TaxaQuery {
taxa(where: {id: {_in: ${taxonEntityIds["taxon"]}}}) {
id
name
upstreamDatabaseIdentifier
let taxonInfo: NextGenEntitiesTypes.Taxon[] = [];
if (taxonEntityIds["taxon"].length > 0) {
const taxaQuery = `
query TaxaQuery {
taxa(where: {id: {_in: ${taxonEntityIds["taxon"]}}}) {
id
name
upstreamDatabaseIdentifier
}
}
accessions(where: {id: {_in: ${taxonEntityIds["accession"]}}}) {
id
accessionId
accessionName
`;

const taxaResp = await get({
args,
context,
serviceType: "entities",
customQuery: taxaQuery,
});
taxonInfo = taxaResp?.data?.taxa || [];
}

let accessionInfo: NextGenEntitiesTypes.Accession[] = [];
if (taxonEntityIds["accession"].length > 0) {
const accessionQuery = `
query AccessionQuery {
accessions(where: {id: {_in: ${taxonEntityIds["accession"]}}}) {
id
accessionId
accessionName
}
}
}
`;
`;

const taxaResp = await get({
args,
context,
serviceType: "entities",
customQuery: taxaQuery,
});
const taxonInfo: NextGenEntitiesTypes.Taxon[] = taxaResp?.data?.taxa || [];
const accessionInfo: NextGenEntitiesTypes.Accession[] = taxaResp?.data?.accessions || [];
const accessionResp = await get({
args,
context,
serviceType: "entities",
customQuery: accessionQuery,
});
accessionInfo = accessionResp?.data?.accessions || [];
}

const nextGenWorkflowRuns: query_SampleForReport_workflow_runs_items[] = workflowsWorkflowRuns.map(workflowRun => {
const consensusGenome = consensusGenomes.find(consensusGenome => {
Expand Down
Loading