ResourceList Query [Question]
eq0rip opened this issue · 3 comments
Hello,
For QuestionnaireList, isn't it enough returning array from resolver as follow ?
[
{ _id: 'teee',
id: 'teee',
resourceType: 'Questionnaire',
title: 'Some title',
status: 'active'
.
.
.
},
{ ... }
]
Everytime I am only getting back
{
"data": {
"QuestionnaireList": {
"entry": null
}
}
}
Below is my query I used in /$graphiql
{
QuestionnaireList(status: "active") {
entry {
resource {
... on Questionnaire {
resourceType
id
}
}
}
}
}
Am I missing something here ?
Below is piece of my resolver
return new Promise((resolve, reject) => {
collection.find(args).toArray((err, questionnaires) => {
if (err) {
logger.error(err);
let error = errorUtils.internal(version, err.message);
return reject(errorUtils.formatErrorForGraphQL(error));
} else {
return resolve(questionnaires);
}
});
});
So I changed my resolver to following
return new Promise((resolve, reject) => {
collection.find(args).toArray((err, questionnaires) => {
if (err) {
logger.error(err);
let error = errorUtils.internal(version, err.message);
return reject(errorUtils.formatErrorForGraphQL(error));
} else {
console.log('questionnaires are', questionnaires);
let finalQuestionnaires = questionnaires.map(singleQuestion => {
return {
resource: singleQuestion
};
});
return resolve({
entry: finalQuestionnaires
});
}
});
});
but got error data is not defined
and solved that by changing code in resourcelist.schema.js.
Am I missing something or there is code error in https://github.com/Asymmetrik/graphql-fhir/blob/master/src/resources/3_0_1/schemas/resourcelist.schema.js
I guess the param name should be data
instead of value
on https://github.com/Asymmetrik/graphql-fhir/blob/master/src/resources/3_0_1/schemas/resourcelist.schema.js#L131
Ahh yes good catch. That is an error in the generated code. I will submit a PR with this updated in all three versions.
Great.