mattpolzin / mattpolzin/JSONAPI
Allow for easier calls to included data
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 81
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
Hi Matt,
We are using this library intensively. However, one thing that is very cumbersome somehow, is working with relationships and included object.
We are looking for way to expose the relationships included data easier. Something like this
let objectDocument = Document(..)
print(objectDocument.name) // attribute
print(objectDocument.relationships.employee.id) // which already works
print(objectDocument.includedRelation(id: objectDocument.relationships.employee.id).name // which doesn't exist but would be nice to have
And maybe something like this for the entire array?
print(objectDocument.includedRelation(relation: objectDocument.relationships.employee) // would return [Employee]
I have seen the examples of all the caches etc but it results in a lot of boilerplate code and messy code imo. Is something like above possible or is this some limitations we have in Swift currently? I would also love to help with a PR myself if you could give some advice on how to approach this :)
Love to hear your thoughts!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Document examples in the issue and review the existing cache examples for how relationships and included objects are currently accessed. Define how includedRelation should resolve a single related object and an entire relationship array, then confirm the proposed API removes the described boilerplate without changing existing relationship behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100