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

Add partial response collection type #10

Open
wants to merge 7 commits into
base: gh-pages
Choose a base branch
from

Conversation

sberserker
Copy link

No description provided.

@ardiesaeidi ardiesaeidi self-assigned this Feb 15, 2019
@ardiesaeidi ardiesaeidi self-requested a review February 15, 2019 00:38
@ardiesaeidi ardiesaeidi removed their assignment Feb 15, 2019
@@ -354,6 +354,36 @@ A `Collection` **MAY** have the following:
}
```

## <a href="#document-components-collection" id="document-components-collection" class="headerlink"></a> Partial Collection (Optional)
Server **MAY** support an ability to return only specific fields requested by client.
A `PartialCollection` is a type of [node](#document-components-node) used to represent a specific resource fields based on query string parameter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per our discussion, i think this should become its own section called Sparse Fields or something along those lines, instead of creating a PartialCollection. This will allow clients to filter resources by attributes while still maintaining what resource they are filtering.

ex.

{
    "@id": "/users?fields=/given_name",
    "@type": "Collection",
    "items": [
        {
            "@id": "/users/1",
            "@type": "User",
            "given_name": "Hubert"
        },
        {
            "@id": "/users/2",
            "@type": "User",
            "given_name": "John"
        }
        ...
    ],
    "total_items": 20
}



 

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way jsonapi does this is similar: https://jsonapi.org/format/#fetching-includes, though a difference here is that includes is additional data that would be fetched if the param was present. Just another example to look at.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like they've added sparse fieldsets to jsonapi now too: https://jsonapi.org/format/#fetching-sparse-fieldsets

Copy link
Member

@thehelix112 thehelix112 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, esp with link to rfc for json pointers as not all folks will know what that is.

@@ -354,6 +354,39 @@ A `Collection` **MAY** have the following:
}
```

## <a href="#document-components-collection" id="document-components-collection" class="headerlink"></a> Sparse Field Sets (Optional)
Server **MAY** support an ability to return only specific fields requested by client.
* `fields`: query string parameter comma delimited list of fields. May include nested json fields using json pointers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest "json pointers" is a link to https://tools.ietf.org/html/rfc6901

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

Successfully merging this pull request may close these issues.

5 participants