Skip to content

Commit

Permalink
Fix grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
psy-q committed Mar 2, 2021
1 parent 60aba26 commit bdfa430
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/sparse_fieldsets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Sparse fieldsets

.. currentmodule:: flask_rest_jsonapi

You can restrict the fields returned by api with the querystring parameter called "fields". It is very useful for performance purpose because fields not returned are not resolved by api. You can use "fields" parameter on any kind of route (classical CRUD route or relationships route) and any kind of http methods as long as method return data.
You can restrict the fields returned by your API using the query string parameter called "fields". It is very useful for performance purposes because fields not returned are not resolved by the API. You can use the "fields" parameter on any kind of route (classical CRUD route or relationships route) and any kind of HTTP methods as long as the method returns data.

.. note::

Examples are not urlencoded for a better readability
Examples are not URL encoded for better readability

The syntax of a fields is like that ::
The syntax of the fields parameter is ::

?fields[<resource_type>]=<list of fields to return>

Expand All @@ -22,20 +22,20 @@ Example:
GET /persons?fields[person]=display_name HTTP/1.1
Accept: application/vnd.api+json

In this example person's display_name is the only field returned by the api. No relationships links are returned so the response is very fast because api doesn't have to compute relationships link and it is a very costly work.
In this example person's display_name is the only field returned by the API. No relationship links are returned so the response is very fast because the API doesn't have to do any expensive computation of relationship links.

You can manage returned fields for the entire response even for included objects

Example:

If you don't want to compute relationships links for included computers of a person you can do something like that
If you don't want to compute relationship links for included computers of a person you can do something like this

.. sourcecode:: http

GET /persons/1?include=computers&fields[computer]=serial HTTP/1.1
Accept: application/vnd.api+json

And of course you can combine both like that:
And of course you can combine both like this:

Example:

Expand All @@ -46,4 +46,4 @@ Example:

.. warning::

If you want to use both "fields" and "include" don't forget to specify the name of the relationship in fields; if you don't the include wont work.
If you want to use both "fields" and "include", don't forget to specify the name of the relationship in "fields"; if you don't, the include wont work.

0 comments on commit bdfa430

Please sign in to comment.