Skip to content

Commit 2c222b1

Browse files
author
Bart Koelman
committed
Corrected terminology: relationships use left/right instead of primary/secondary
1 parent 52b3773 commit 2c222b1

30 files changed

+210
-210
lines changed

docs/internals/queries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Processing a request involves the following steps:
1818
- The readers also implement `IQueryConstraintProvider`, which exposes expressions through `ExpressionInScope` objects.
1919
- `QueryLayerComposer` (used from `JsonApiResourceService`) collects all query constraints.
2020
- It combines them with default options and `IResourceDefinition` overrides and composes a tree of `QueryLayer` objects.
21-
- It lifts the tree for nested endpoints like /blogs/1/articles and rewrites includes.
21+
- It lifts the tree for secondary endpoints like /blogs/1/articles and rewrites includes.
2222
- `JsonApiResourceService` contains no more usage of `IQueryable`.
2323
- `EntityFrameworkCoreRepository` delegates to `QueryableBuilder` to transform the `QueryLayer` tree into `IQueryable` expression trees.
2424
`QueryBuilder` depends on `QueryClauseBuilder` implementations that visit the tree nodes, transforming them to `System.Linq.Expression` equivalents.

docs/usage/reading/including-relationships.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ which is equivalent to:
6262
GET /api/articles?include=author&include=author.livingAddress&include=author.livingAddress.country
6363
```
6464

65-
This can be used on nested endpoints too:
65+
This can be used on secondary endpoints too:
6666

6767
```http
6868
GET /api/blogs/1/articles?include=author.livingAddress.country

docs/usage/reading/pagination.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ Resources can be paginated. This request would fetch the second page of 10 artic
66
GET /articles?page[size]=10&page[number]=2 HTTP/1.1
77
```
88

9-
## Nesting
10-
11-
Pagination can be used on nested endpoints, such as:
9+
Pagination can be used on secondary endpoints, such as:
1210

1311
```http
1412
GET /blogs/1/articles?page[number]=2 HTTP/1.1

docs/usage/reading/sorting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ GET /api/blogs?sort=count(articles) HTTP/1.1
3434

3535
This sorts the list of blogs by their number of articles.
3636

37-
## Nesting
37+
## Secondary endpoints
3838

39-
Sorting can be used on nested endpoints, such as:
39+
Sorting can be used on secondary endpoints, such as:
4040

4141
```http
4242
GET /api/blogs/1/articles?sort=caption HTTP/1.1

docs/usage/reading/sparse-fieldset-selection.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
As an alternative to returning all fields (attributes and relationships) from a resource, the `fields[]` query string parameter can be used to select a subset.
44
Put the resource type to apply the fieldset on between the brackets.
5-
This can be used on the resource being requested, as well as on nested endpoints and/or included resources.
5+
This can be used on primary and secondary endpoints. The selection is applied on both primary and included resources.
66

7-
Top-level example:
7+
Primary endpoint example:
88

99
```http
1010
GET /articles?fields[articles]=title,body,comments HTTP/1.1
1111
```
1212

13-
Nested endpoint example:
13+
Secondary endpoint example:
1414

1515
```http
1616
GET /api/blogs/1/articles?fields[articles]=title,body,comments HTTP/1.1

src/Examples/NoEntityFrameworkExample/Services/WorkItemService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public async Task<WorkItem> CreateAsync(WorkItem resource, CancellationToken can
7373
return workItems.Single();
7474
}
7575

76-
public Task AddToToManyRelationshipAsync(int primaryId, string relationshipName, ISet<IIdentifiable> secondaryResourceIds,
76+
public Task AddToToManyRelationshipAsync(int leftId, string relationshipName, ISet<IIdentifiable> rightResourceIds,
7777
CancellationToken cancellationToken)
7878
{
7979
throw new NotImplementedException();
@@ -84,7 +84,7 @@ public Task<WorkItem> UpdateAsync(int id, WorkItem resource, CancellationToken c
8484
throw new NotImplementedException();
8585
}
8686

87-
public Task SetRelationshipAsync(int primaryId, string relationshipName, object secondaryResourceIds, CancellationToken cancellationToken)
87+
public Task SetRelationshipAsync(int leftId, string relationshipName, object rightValue, CancellationToken cancellationToken)
8888
{
8989
throw new NotImplementedException();
9090
}
@@ -99,7 +99,7 @@ public async Task DeleteAsync(int id, CancellationToken cancellationToken)
9999
}, cancellationToken: cancellationToken)));
100100
}
101101

102-
public Task RemoveFromToManyRelationshipAsync(int primaryId, string relationshipName, ISet<IIdentifiable> secondaryResourceIds,
102+
public Task RemoveFromToManyRelationshipAsync(int leftId, string relationshipName, ISet<IIdentifiable> rightResourceIds,
103103
CancellationToken cancellationToken)
104104
{
105105
throw new NotImplementedException();

src/JsonApiDotNetCore/AtomicOperations/Processors/AddToRelationshipProcessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public virtual async Task<OperationContainer> ProcessAsync(OperationContainer op
2626
{
2727
ArgumentGuard.NotNull(operation, nameof(operation));
2828

29-
var primaryId = (TId)operation.Resource.GetTypedId();
30-
ISet<IIdentifiable> secondaryResourceIds = operation.GetSecondaryResources();
29+
var leftId = (TId)operation.Resource.GetTypedId();
30+
ISet<IIdentifiable> rightResourceIds = operation.GetSecondaryResources();
3131

32-
await _service.AddToToManyRelationshipAsync(primaryId, operation.Request.Relationship.PublicName, secondaryResourceIds, cancellationToken);
32+
await _service.AddToToManyRelationshipAsync(leftId, operation.Request.Relationship.PublicName, rightResourceIds, cancellationToken);
3333

3434
return null;
3535
}

src/JsonApiDotNetCore/AtomicOperations/Processors/RemoveFromRelationshipProcessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public virtual async Task<OperationContainer> ProcessAsync(OperationContainer op
2626
{
2727
ArgumentGuard.NotNull(operation, nameof(operation));
2828

29-
var primaryId = (TId)operation.Resource.GetTypedId();
30-
ISet<IIdentifiable> secondaryResourceIds = operation.GetSecondaryResources();
29+
var leftId = (TId)operation.Resource.GetTypedId();
30+
ISet<IIdentifiable> rightResourceIds = operation.GetSecondaryResources();
3131

32-
await _service.RemoveFromToManyRelationshipAsync(primaryId, operation.Request.Relationship.PublicName, secondaryResourceIds, cancellationToken);
32+
await _service.RemoveFromToManyRelationshipAsync(leftId, operation.Request.Relationship.PublicName, rightResourceIds, cancellationToken);
3333

3434
return null;
3535
}

src/JsonApiDotNetCore/AtomicOperations/Processors/SetRelationshipProcessor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public virtual async Task<OperationContainer> ProcessAsync(OperationContainer op
2929
{
3030
ArgumentGuard.NotNull(operation, nameof(operation));
3131

32-
var primaryId = (TId)operation.Resource.GetTypedId();
32+
var leftId = (TId)operation.Resource.GetTypedId();
3333
object rightValue = GetRelationshipRightValue(operation);
3434

35-
await _service.SetRelationshipAsync(primaryId, operation.Request.Relationship.PublicName, rightValue, cancellationToken);
35+
await _service.SetRelationshipAsync(leftId, operation.Request.Relationship.PublicName, rightValue, cancellationToken);
3636

3737
return null;
3838
}

src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -211,36 +211,36 @@ public virtual async Task<IActionResult> PostAsync([FromBody] TResource resource
211211
/// Adds resources to a to-many relationship. Example: POST /articles/1/revisions HTTP/1.1
212212
/// </summary>
213213
/// <param name="id">
214-
/// The identifier of the primary resource.
214+
/// Identifies the left side of the relationship.
215215
/// </param>
216216
/// <param name="relationshipName">
217217
/// The relationship to add resources to.
218218
/// </param>
219-
/// <param name="secondaryResourceIds">
219+
/// <param name="rightResourceIds">
220220
/// The set of resources to add to the relationship.
221221
/// </param>
222222
/// <param name="cancellationToken">
223223
/// Propagates notification that request handling should be canceled.
224224
/// </param>
225-
public virtual async Task<IActionResult> PostRelationshipAsync(TId id, string relationshipName, [FromBody] ISet<IIdentifiable> secondaryResourceIds,
225+
public virtual async Task<IActionResult> PostRelationshipAsync(TId id, string relationshipName, [FromBody] ISet<IIdentifiable> rightResourceIds,
226226
CancellationToken cancellationToken)
227227
{
228228
_traceWriter.LogMethodStart(new
229229
{
230230
id,
231231
relationshipName,
232-
secondaryResourceIds
232+
rightResourceIds
233233
});
234234

235235
ArgumentGuard.NotNullNorEmpty(relationshipName, nameof(relationshipName));
236-
ArgumentGuard.NotNull(secondaryResourceIds, nameof(secondaryResourceIds));
236+
ArgumentGuard.NotNull(rightResourceIds, nameof(rightResourceIds));
237237

238238
if (_addToRelationship == null)
239239
{
240240
throw new RequestMethodNotAllowedException(HttpMethod.Post);
241241
}
242242

243-
await _addToRelationship.AddToToManyRelationshipAsync(id, relationshipName, secondaryResourceIds, cancellationToken);
243+
await _addToRelationship.AddToToManyRelationshipAsync(id, relationshipName, rightResourceIds, cancellationToken);
244244

245245
return NoContent();
246246
}
@@ -279,25 +279,25 @@ public virtual async Task<IActionResult> PatchAsync(TId id, [FromBody] TResource
279279
/// /articles/1/relationships/revisions HTTP/1.1
280280
/// </summary>
281281
/// <param name="id">
282-
/// The identifier of the primary resource.
282+
/// Identifies the left side of the relationship.
283283
/// </param>
284284
/// <param name="relationshipName">
285285
/// The relationship for which to perform a complete replacement.
286286
/// </param>
287-
/// <param name="secondaryResourceIds">
287+
/// <param name="rightValue">
288288
/// The resource or set of resources to assign to the relationship.
289289
/// </param>
290290
/// <param name="cancellationToken">
291291
/// Propagates notification that request handling should be canceled.
292292
/// </param>
293-
public virtual async Task<IActionResult> PatchRelationshipAsync(TId id, string relationshipName, [FromBody] object secondaryResourceIds,
293+
public virtual async Task<IActionResult> PatchRelationshipAsync(TId id, string relationshipName, [FromBody] object rightValue,
294294
CancellationToken cancellationToken)
295295
{
296296
_traceWriter.LogMethodStart(new
297297
{
298298
id,
299299
relationshipName,
300-
secondaryResourceIds
300+
rightValue
301301
});
302302

303303
ArgumentGuard.NotNullNorEmpty(relationshipName, nameof(relationshipName));
@@ -307,7 +307,7 @@ public virtual async Task<IActionResult> PatchRelationshipAsync(TId id, string r
307307
throw new RequestMethodNotAllowedException(HttpMethod.Patch);
308308
}
309309

310-
await _setRelationship.SetRelationshipAsync(id, relationshipName, secondaryResourceIds, cancellationToken);
310+
await _setRelationship.SetRelationshipAsync(id, relationshipName, rightValue, cancellationToken);
311311

312312
return NoContent();
313313
}
@@ -336,36 +336,36 @@ public virtual async Task<IActionResult> DeleteAsync(TId id, CancellationToken c
336336
/// Removes resources from a to-many relationship. Example: DELETE /articles/1/relationships/revisions HTTP/1.1
337337
/// </summary>
338338
/// <param name="id">
339-
/// The identifier of the primary resource.
339+
/// Identifies the left side of the relationship.
340340
/// </param>
341341
/// <param name="relationshipName">
342342
/// The relationship to remove resources from.
343343
/// </param>
344-
/// <param name="secondaryResourceIds">
344+
/// <param name="rightResourceIds">
345345
/// The set of resources to remove from the relationship.
346346
/// </param>
347347
/// <param name="cancellationToken">
348348
/// Propagates notification that request handling should be canceled.
349349
/// </param>
350-
public virtual async Task<IActionResult> DeleteRelationshipAsync(TId id, string relationshipName, [FromBody] ISet<IIdentifiable> secondaryResourceIds,
350+
public virtual async Task<IActionResult> DeleteRelationshipAsync(TId id, string relationshipName, [FromBody] ISet<IIdentifiable> rightResourceIds,
351351
CancellationToken cancellationToken)
352352
{
353353
_traceWriter.LogMethodStart(new
354354
{
355355
id,
356356
relationshipName,
357-
secondaryResourceIds
357+
rightResourceIds
358358
});
359359

360360
ArgumentGuard.NotNullNorEmpty(relationshipName, nameof(relationshipName));
361-
ArgumentGuard.NotNull(secondaryResourceIds, nameof(secondaryResourceIds));
361+
ArgumentGuard.NotNull(rightResourceIds, nameof(rightResourceIds));
362362

363363
if (_removeFromRelationship == null)
364364
{
365365
throw new RequestMethodNotAllowedException(HttpMethod.Delete);
366366
}
367367

368-
await _removeFromRelationship.RemoveFromToManyRelationshipAsync(id, relationshipName, secondaryResourceIds, cancellationToken);
368+
await _removeFromRelationship.RemoveFromToManyRelationshipAsync(id, relationshipName, rightResourceIds, cancellationToken);
369369

370370
return NoContent();
371371
}

src/JsonApiDotNetCore/Controllers/JsonApiCommandController.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ public override async Task<IActionResult> PostAsync([FromBody] TResource resourc
4040

4141
/// <inheritdoc />
4242
[HttpPost("{id}/relationships/{relationshipName}")]
43-
public override async Task<IActionResult> PostRelationshipAsync(TId id, string relationshipName, [FromBody] ISet<IIdentifiable> secondaryResourceIds,
43+
public override async Task<IActionResult> PostRelationshipAsync(TId id, string relationshipName, [FromBody] ISet<IIdentifiable> rightResourceIds,
4444
CancellationToken cancellationToken)
4545
{
46-
return await base.PostRelationshipAsync(id, relationshipName, secondaryResourceIds, cancellationToken);
46+
return await base.PostRelationshipAsync(id, relationshipName, rightResourceIds, cancellationToken);
4747
}
4848

4949
/// <inheritdoc />
@@ -55,10 +55,10 @@ public override async Task<IActionResult> PatchAsync(TId id, [FromBody] TResourc
5555

5656
/// <inheritdoc />
5757
[HttpPatch("{id}/relationships/{relationshipName}")]
58-
public override async Task<IActionResult> PatchRelationshipAsync(TId id, string relationshipName, [FromBody] object secondaryResourceIds,
58+
public override async Task<IActionResult> PatchRelationshipAsync(TId id, string relationshipName, [FromBody] object rightValue,
5959
CancellationToken cancellationToken)
6060
{
61-
return await base.PatchRelationshipAsync(id, relationshipName, secondaryResourceIds, cancellationToken);
61+
return await base.PatchRelationshipAsync(id, relationshipName, rightValue, cancellationToken);
6262
}
6363

6464
/// <inheritdoc />
@@ -70,10 +70,10 @@ public override async Task<IActionResult> DeleteAsync(TId id, CancellationToken
7070

7171
/// <inheritdoc />
7272
[HttpDelete("{id}/relationships/{relationshipName}")]
73-
public override async Task<IActionResult> DeleteRelationshipAsync(TId id, string relationshipName, [FromBody] ISet<IIdentifiable> secondaryResourceIds,
73+
public override async Task<IActionResult> DeleteRelationshipAsync(TId id, string relationshipName, [FromBody] ISet<IIdentifiable> rightResourceIds,
7474
CancellationToken cancellationToken)
7575
{
76-
return await base.DeleteRelationshipAsync(id, relationshipName, secondaryResourceIds, cancellationToken);
76+
return await base.DeleteRelationshipAsync(id, relationshipName, rightResourceIds, cancellationToken);
7777
}
7878
}
7979

src/JsonApiDotNetCore/Controllers/JsonApiController.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ public override async Task<IActionResult> PostAsync([FromBody] TResource resourc
8181

8282
/// <inheritdoc />
8383
[HttpPost("{id}/relationships/{relationshipName}")]
84-
public override async Task<IActionResult> PostRelationshipAsync(TId id, string relationshipName, [FromBody] ISet<IIdentifiable> secondaryResourceIds,
84+
public override async Task<IActionResult> PostRelationshipAsync(TId id, string relationshipName, [FromBody] ISet<IIdentifiable> rightResourceIds,
8585
CancellationToken cancellationToken)
8686
{
87-
return await base.PostRelationshipAsync(id, relationshipName, secondaryResourceIds, cancellationToken);
87+
return await base.PostRelationshipAsync(id, relationshipName, rightResourceIds, cancellationToken);
8888
}
8989

9090
/// <inheritdoc />
@@ -96,10 +96,10 @@ public override async Task<IActionResult> PatchAsync(TId id, [FromBody] TResourc
9696

9797
/// <inheritdoc />
9898
[HttpPatch("{id}/relationships/{relationshipName}")]
99-
public override async Task<IActionResult> PatchRelationshipAsync(TId id, string relationshipName, [FromBody] object secondaryResourceIds,
99+
public override async Task<IActionResult> PatchRelationshipAsync(TId id, string relationshipName, [FromBody] object rightValue,
100100
CancellationToken cancellationToken)
101101
{
102-
return await base.PatchRelationshipAsync(id, relationshipName, secondaryResourceIds, cancellationToken);
102+
return await base.PatchRelationshipAsync(id, relationshipName, rightValue, cancellationToken);
103103
}
104104

105105
/// <inheritdoc />
@@ -111,10 +111,10 @@ public override async Task<IActionResult> DeleteAsync(TId id, CancellationToken
111111

112112
/// <inheritdoc />
113113
[HttpDelete("{id}/relationships/{relationshipName}")]
114-
public override async Task<IActionResult> DeleteRelationshipAsync(TId id, string relationshipName, [FromBody] ISet<IIdentifiable> secondaryResourceIds,
114+
public override async Task<IActionResult> DeleteRelationshipAsync(TId id, string relationshipName, [FromBody] ISet<IIdentifiable> rightResourceIds,
115115
CancellationToken cancellationToken)
116116
{
117-
return await base.DeleteRelationshipAsync(id, relationshipName, secondaryResourceIds, cancellationToken);
117+
return await base.DeleteRelationshipAsync(id, relationshipName, rightResourceIds, cancellationToken);
118118
}
119119
}
120120

src/JsonApiDotNetCore/Queries/Internal/Parsing/SparseFieldTypeParser.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ private ResourceContext ParseResourceName()
5454
throw new QueryParseException("Resource type expected.");
5555
}
5656

57-
private ResourceContext GetResourceContext(string resourceName)
57+
private ResourceContext GetResourceContext(string publicName)
5858
{
59-
ResourceContext resourceContext = _resourceContextProvider.GetResourceContext(resourceName);
59+
ResourceContext resourceContext = _resourceContextProvider.GetResourceContext(publicName);
6060

6161
if (resourceContext == null)
6262
{
63-
throw new QueryParseException($"Resource type '{resourceName}' does not exist.");
63+
throw new QueryParseException($"Resource type '{publicName}' does not exist.");
6464
}
6565

6666
return resourceContext;

0 commit comments

Comments
 (0)