Commit c8b0816
committed
Allow resource level links to be defined
Graphiti supports links at a relationship level and at the top-level of the
jsonapi document.
Relationship level links are mainly to support lazy loading, and top level links
are used solely for pagination.
This commit adds support for defining links at the resource level.
These links could be used to provide the URL to the resource, or alternative
representation of the resource, or even actions to perform against the resource.
{
"data": {
"id": 1,
"type": "tests",
"attributes": {},
"relationships": {},
"links": {
"self": "http://test.com/api/v1/tests/1"
}
}
}
To define a link on a resource:
link :self do |model|
"#{self.endpoint[:url]}/#{model.id}"
end1 parent 1cef192 commit c8b0816
File tree
4 files changed
+21
-0
lines changed- lib/graphiti
- resource
4 files changed
+21
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
151 | 162 | | |
152 | 163 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| 201 | + | |
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
| |||
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
239 | 244 | | |
240 | 245 | | |
241 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
149 | 153 | | |
150 | 154 | | |
151 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
0 commit comments