# Self Links and Inheritance of Sparse Fieldsets

**URL:** <https://discuss.jsonapi.org/t/self-links-and-inheritance-of-sparse-fieldsets/1817>\
**Category:** Uncategorized\
**Created:** [January 26, 2020, 10:17am UTC](https://discuss.jsonapi.org/t/self-links-and-inheritance-of-sparse-fieldsets/1817 "2020-01-26T10:17:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kramer](https://avatars.discourse-cdn.com/v4/letter/k/97f17d/32.png) [@kramer](https://discuss.jsonapi.org/u/kramer)\
**Post date:** [January 26, 2020, 10:17am UTC](https://discuss.jsonapi.org/t/self-links-and-inheritance-of-sparse-fieldsets/1817/1 "2020-01-26T10:17:30Z")

</div>

Hello,

as I understand a `self` link at any location in a document is basically the link to the same response relative to the documents path.

So if using Sparse Fieldsets I assume that it should be inherited to any self link as well. Not doing so would result in a non matching response if a self link was followed.

Is this correct?  
If yes, what `links` attribute could be used as a reference to the resource object with full details?

```
{
	"data": [
        {
			"attributes": {
				"name": "First Pool",
				"description": "A good pool"
			},
			"id": "5c071fae-01fa-4f18-b692-7bc6fc98331f",
			"links": {
				"self": "/pools/5c071fae-01fa-4f18-b692-7bc6fc98331f?fields[pools]=name,description"
			},
			"type": "pools"
		},
		{
			"attributes": {
				"name": "Second Pool",
				"description": "Another good pool"
			},
			"id": "a0d6a8c1-eaed-43ed-8937-f3c5387ee78a",
			"links": {
				"self": "/pools/a0d6a8c1-eaed-43ed-8937-f3c5387ee78a?fields[pools]=name,description"
			},
			"type": "pools"
		}
	],
	"links": {
		"self": "/pools?fields[pools]=name,description"
	}
}

```

Not including the Sparse Fieldsets in a query might produce other reponses.

```
{
	"data": {
        "attributes": {
	        "name": "First Pool",
	        "description": "A good pool",
            "city": "Berlin",
            "country": "Germany",
            "active": true
	    },
        "id": "5c071fae-01fa-4f18-b692-7bc6fc98331f",
        "links": {
            "self": "/pools/5c071fae-01fa-4f18-b692-7bc6fc98331f"
        },
        "type": "pools",
    },
    "links": {
        "self": "/pools/5c071fae-01fa-4f18-b692-7bc6fc98331f"
    }
}
```

---

<div class="post-metadata">

**Author:** ![lode](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/lode/32/592_2.png) [@lode](https://discuss.jsonapi.org/u/lode)\
**Post date:** [March 12, 2021, 11:39am UTC](https://discuss.jsonapi.org/t/self-links-and-inheritance-of-sparse-fieldsets/1817/2 "2021-03-12T11:39:54Z")

</div>

If you’re still looking for the answer, the sparse fieldsets should **not** be present in a resource-level self link. Otherwise the client has to remove those query parameters before requesting other data from that endpoint.

See also [Top-level links vs. resource-level links for item resources](https://discuss.jsonapi.org/t/top-level-links-vs-resource-level-links-for-item-resources/2032). Main take away is that the resource-level self link **identifies** the resource, not how you want to have it represented in a specific call.

Thus a request for `/pools?fields[pools]=name,description` returns:

```auto
{
	"data": [
        {
			"attributes": {
				"name": "First Pool",
				"description": "A good pool"
			},
			"id": "5c071fae-01fa-4f18-b692-7bc6fc98331f",
			"links": {
				"self": "/pools/5c071fae-01fa-4f18-b692-7bc6fc98331f"
			},
			"type": "pools"
		},
		{
			"attributes": {
				"name": "Second Pool",
				"description": "Another good pool"
			},
			"id": "a0d6a8c1-eaed-43ed-8937-f3c5387ee78a",
			"links": {
				"self": "/pools/a0d6a8c1-eaed-43ed-8937-f3c5387ee78a"
			},
			"type": "pools"
		}
	],
	"links": {
		"self": "/pools?fields[pools]=name,description"
	}
}

```

The client can then request the extra data if a user interacts with one of the resources using `/pools/5c071fae-01fa-4f18-b692-7bc6fc98331f?fields[pools]=city,country,active`:

```auto
{
	"data": {
        "attributes": {
            "city": "Berlin",
            "country": "Germany",
            "active": true
	    },
        "id": "5c071fae-01fa-4f18-b692-7bc6fc98331f",
        "links": {
            "self": "/pools/5c071fae-01fa-4f18-b692-7bc6fc98331f"
        },
        "type": "pools",
    },
    "links": {
        "self": "/pools/5c071fae-01fa-4f18-b692-7bc6fc98331f?fields[pools]=city,country,active"
    }
}

```
