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

ResourceList Query [Question] #19

Closed
eq0rip opened this issue Jan 23, 2019 · 3 comments · Fixed by #20
Closed

ResourceList Query [Question] #19

eq0rip opened this issue Jan 23, 2019 · 3 comments · Fixed by #20
Assignees
Labels
bug Something isn't working

Comments

@eq0rip
Copy link

eq0rip commented Jan 23, 2019

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);
		      }
		    });
	});
@eq0rip
Copy link
Author

eq0rip commented Jan 23, 2019

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

@Robert-W Robert-W self-assigned this Jan 23, 2019
@Robert-W Robert-W added the bug Something isn't working label Jan 23, 2019
@Robert-W
Copy link
Contributor

Ahh yes good catch. That is an error in the generated code. I will submit a PR with this updated in all three versions.

@eq0rip
Copy link
Author

eq0rip commented Jan 23, 2019

Great. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants