-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CTC-2299 Extend filtering examples on linked items
- Loading branch information
Showing
8 changed files
with
113 additions
and
25 deletions.
There are no files selected for viewing
26 changes: 22 additions & 4 deletions
26
graphql/filter-content/filtering_get_items_by_linked_item.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,35 @@ | ||
# Gets items attributed to Jane. | ||
query GetArticlesByAuthor { | ||
article_All(where: {author: {containsAll: ["jane_doe"]}}) { | ||
// # Gets a list of items where the 'my_page' item is used in the 'navigation' element. | ||
query GetItemsByUsedIn { | ||
page_All(where: {navigation: {containsAll: ["my_page"]}}) { | ||
items { | ||
title | ||
} | ||
} | ||
} | ||
|
||
# Gets items attributed to at least Jane, John, or both. | ||
# Gets items linked to at least Jane, John, or both. | ||
query GetArticlesByOneOfAuthors { | ||
article_All(where: {author: {containsAny: ["jane_doe", "john_wick"]}}) { | ||
items { | ||
title | ||
} | ||
} | ||
} | ||
|
||
# Gets pages linking travel insurance as their subpage. | ||
query GetArticlesTaggedWithATerm { | ||
article_All(where: {subpages: {containsAll: ["travel_insurance"]}}) { | ||
items { | ||
title | ||
} | ||
} | ||
} | ||
|
||
# Gets pages linking at least travel insurance, car insurance, or both as their subpage. | ||
query GetArticlesTaggedWithTerms { | ||
article_All(where: {subpages: {containsAny: ["travel_insurance", "car_insurance"]}}) { | ||
items { | ||
title | ||
} | ||
} | ||
} |
20 changes: 17 additions & 3 deletions
20
java/filter-content/filtering_get_items_by_linked_item.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,28 @@ | ||
// Gets items attributed to Jane. | ||
// Gets a list of items where the 'my_page' item is used in the 'navigation' element. | ||
CompletionStage<ContentItemsListingResponse> items = client.getItems( | ||
DeliveryParameterBuilder.params() | ||
.filterContains("elements.author", "jane_doe") | ||
.filterContains("elements.navigation", "my_page") | ||
.build() | ||
); | ||
|
||
|
||
// Gets items attributed to at least Jane, John, or both. | ||
// Gets items linked to at least Jane, John, or both. | ||
CompletionStage<ContentItemsListingResponse> items = client.getItems( | ||
DeliveryParameterBuilder.params() | ||
.filterAny("elements.author", "jane_doe", "john_wick") | ||
.build() | ||
); | ||
|
||
// Gets pages linking travel insurance as their subpage. | ||
CompletionStage<ContentItemsListingResponse> items = client.getItems( | ||
DeliveryParameterBuilder.params() | ||
.filterContains("elements.subpages", "travel_insurance") | ||
.build() | ||
); | ||
|
||
// Gets pages linking at least travel insurance, car insurance, or both as their subpage. | ||
CompletionStage<ContentItemsListingResponse> items = client.getItems( | ||
DeliveryParameterBuilder.params() | ||
.filterAny("elements.subpages", "travel_insurance", "car_insurance") | ||
.build() | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
// Gets items attributed to Jane. | ||
// Gets a list of items where the 'my_page' item is used in the 'navigation' element. | ||
const response = await deliveryClient.items() | ||
.containsFilter('elements.author', ['jane_doe']) | ||
.containsFilter('elements.navigation', ['my_page']) | ||
.toPromise(); | ||
|
||
// Gets items attributed to at least Jane, John, or both. | ||
// Gets items linked to at least Jane, John, or both. | ||
const response = await deliveryClient.items() | ||
.anyFilter('elements.author', ['jane_doe', 'john_wick']) | ||
.toPromise(); | ||
|
||
// Gets pages linking travel insurance as their subpage. | ||
const response = await deliveryClient.items() | ||
.containsFilter('elements.subpages', ['travel_insurance']) | ||
.toPromise(); | ||
|
||
// Gets pages linking at least travel insurance, car insurance, or both as their subpage. | ||
const response = await deliveryClient.items() | ||
.anyFilter('elements.subpages', ['travel_insurance', 'car_insurance']) | ||
.toPromise(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
// Gets items attributed to Jane. | ||
// Gets a list of items where the 'my_page' item is used in the 'navigation' element. | ||
IDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( | ||
new ContainsFilter("elements.author", "jane_doe") | ||
new ContainsFilter("elements.navigation", "my_page") | ||
); | ||
|
||
// Gets items attributed to at least Jane, John, or both. | ||
// Gets items linked to at least Jane, John, or both. | ||
IDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( | ||
new AnyFilter("elements.author", "jane_doe", "john_wick") | ||
); | ||
|
||
// Gets pages linking travel insurance as their subpage. | ||
IDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( | ||
new ContainsFilter("elements.subpages", "travel_insurance") | ||
); | ||
|
||
// Gets pages linking at least travel insurance, car insurance, or both as their subpage. | ||
IDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( | ||
new AnyFilter("elements.subpages", "travel_insurance", "car_insurance") | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
<?php | ||
// Gets items attributed to Jane. | ||
// Gets a list of items where the 'my_page' item is used in the 'navigation' element. | ||
$items = $client->getItems((new QueryParams()) | ||
->contains('elements.author', 'jane_doe')); | ||
->contains('elements.navigation', 'my_page')); | ||
|
||
// Gets items attributed to at least Jane, John, or both. | ||
// Gets items linked to at least Jane, John, or both. | ||
$items = $client->getItems((new QueryParams()) | ||
->any('elements.author', ['jane_doe','john_wick'])); | ||
?> | ||
|
||
<?php | ||
// Gets pages linking travel insurance as their subpage. | ||
$items = $client->getItems((new QueryParams()) | ||
->contains('elements.subpages', 'travel_insurance')); | ||
|
||
// Gets pages linking at least travel insurance, car insurance, or both as their subpage. | ||
$items = $client->getItems((new QueryParams()) | ||
->any('elements.subpages', ['travel_insurance','car_insurance'])); | ||
?> |
16 changes: 13 additions & 3 deletions
16
rest/filter-content/filtering_get_items_by_linked_item.curl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
# Gets items attributed to Jane. | ||
# Gets a list of items where the 'my_page' item is used in the 'navigation' element. | ||
curl --request GET \ | ||
--url 'https://deliver.kontent.ai/<YOUR_ENVIRONMENT_ID>/items?elements.author[contains]=jane_doe' \ | ||
--url 'https://deliver.kontent.ai/<YOUR_ENVIRONMENT_ID>/items?elements.navigation[contains]=my_page' \ | ||
--header 'content-type: application/json' | ||
|
||
# Gets items attributed to at least Jane, John, or both. | ||
# Gets items linked to at least Jane, John, or both. | ||
curl --request GET \ | ||
--url 'https://deliver.kontent.ai/<YOUR_ENVIRONMENT_ID>/items?elements.author[any]=jane_doe,john_wick' \ | ||
--header 'content-type: application/json' | ||
|
||
# Gets pages linking travel insurance as their subpage. | ||
curl --request GET \ | ||
--url 'https://deliver.kontent.ai/<YOUR_ENVIRONMENT_ID>/items?elements.subpages[contains]=travel_insurance' \ | ||
--header 'content-type: application/json' | ||
|
||
# Gets pages linking at least travel insurance, car insurance, or both as their subpage. | ||
curl --request GET \ | ||
--url 'https://deliver.kontent.ai/<YOUR_ENVIRONMENT_ID>/items?elements.subpages[any]=travel_insurance,car_insurance' \ | ||
--header 'content-type: application/json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
# Gets items attributed to Jane. | ||
delivery_client.items('elements.author'.contains('jane_doe')) | ||
# Gets a list of items where the 'my_page' item is used in the 'navigation' element. | ||
delivery_client.items('elements.navigation'.contains('my_page')) | ||
|
||
# Gets items attributed to at least Jane, John, or both. | ||
# Gets items linked to at least Jane, John, or both. | ||
delivery_client.items('elements.author'.any('jane_doe', 'john_wick')) | ||
|
||
# Gets pages linking travel insurance as their subpage. | ||
delivery_client.items('elements.subpages'.contains('travel_insurance')) | ||
|
||
# Gets pages linking at least travel insurance, car insurance, or both as their subpage. | ||
delivery_client.items('elements.subpages'.any('travel_insurance', 'car_insurance')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
// Gets items attributed to Jane. | ||
// # Gets a list of items where the 'my_page' item is used in the 'navigation' element. | ||
const response = await deliveryClient.items() | ||
.containsFilter('elements.author', ['jane_doe']) | ||
.containsFilter('elements.navigation', ['my_page']) | ||
.toPromise(); | ||
|
||
// Gets items attributed to at least Jane, John, or both. | ||
// Gets items linked to at least Jane, John, or both. | ||
const response = await deliveryClient.items() | ||
.anyFilter('elements.author', ['jane_doe', 'john_wick']) | ||
.toPromise(); | ||
|
||
// Gets pages linking travel insurance as their subpage. | ||
const response = await deliveryClient.items() | ||
.containsFilter('elements.subpages', ['travel_insurance']) | ||
.toPromise(); | ||
|
||
// Gets pages linking at least travel insurance, car insurance, or both as their subpage. | ||
const response = await deliveryClient.items() | ||
.anyFilter('elements.subpages', ['travel_insurance', 'car_insurance']) | ||
.toPromise(); |