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

Composition fails if reference field is undefined #390

Closed
jimlambie opened this Issue Feb 26, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@jimlambie
Copy link
Member

jimlambie commented Feb 26, 2018

Expected behaviour

A document with reference fields should return fully composed regardless of whether optional fields have been completed or not.

Actual behaviour

If a reference field does not hold a value, the composition process exits prematurely and a non-composed document is returned.

Steps to reproduce the problem

Create a collection with at least one reference field. Add documents to the collection which have one or more reference fields undefined. Perform a GET request to the collection - all reference fields should hold original ID values only, i.e. no composition has been performed.

Package details

@dadi/api@3.0.0
@dadi/api-mongodb@3.5.0

@jimlambie jimlambie added the type: bug label Feb 26, 2018

@jimlambie

This comment has been minimized.

Copy link
Member Author

jimlambie commented Feb 27, 2018

An update to this. In general, composition works if a reference field doesn't exist in a document. This works fine when returning a single document. However when returning a result set containing multiple documents, the set of reference fields to attempt composition for is a merged array of reference field names extracted from the full set of documents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment