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

Load persons with relationships? #1

Open
justincy opened this issue Jul 15, 2015 · 2 comments
Open

Load persons with relationships? #1

justincy opened this issue Jul 15, 2015 · 2 comments

Comments

@justincy
Copy link
Contributor

From @jimmyz:

For the Read Family, the code is currently using loadParentRelationships, loadSpouseRelationships, and loadChildRelationships.

You may consider using readParents, readSpouses, and readChildren methods. These should provide the relationships and the person objects in one call.

The loadParentRelationships method uses the "Relationships to Parents" REST resource, which only contains relationship data. https://familysearch.org/developers/docs/api/tree/Relationships_to_Parents_resource

The readParents method uses the "Parents of a Person" REST resource, which contains the parent person objects and the relationship https://familysearch.org/developers/docs/api/tree/Read_Parents_of_a_Person_usecase

@justincy
Copy link
Contributor Author

I updated the Read Family example to use the different endpoints which returns the persons. In the commit you'll notice that the example is much more complex now.

The endpoints don't return all persons in the relationships, just the particular type that was requested.

  • readParents only returns the parents, not the primary person (which is always the child).
  • readSpouses only returns the spouses, not the primary person.
  • readChildren only returns the children, not the parents. One of the parents is the primary person, the other parent may or may not be a spouse. I left a comment in the code discussing this.

The new states returned by readParents, readSpouses, and readChildren did not make it easy to assemble the resulting relationships. It would have been easier if they all had a getPerson() method. I opened an issue on the SDK about this.

Processing these relationships, as currently shown in the example, is painful. There must be a better way. Given the async nature of PHP, I would rather request all the relationships without the persons then request the persons one at a time as I needed them even though that would be slower.

In a case like this where we're processing all relationships, using the Persons with Relationships resource would be much easier.

@jimmyz
Copy link
Contributor

jimmyz commented Jul 16, 2015

I agree that the example is now much more complex. However, it is a common use case. We should provide an alternative implementation using Persons with Relationships. It will be interesting to see how things play out in code and performance.

My thought is that we should use the example to improve the SDK functionality, much like you've already suggested with the getPerson() method issue.

My goal is for the SDK to provide an interface that allows the common use cases to be handled in an elegant way. I think it is moving that direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants