Skip to content

Commit 5e2935e

Browse files
committed
fix(url): adding in url resolving
1 parent bcb33b4 commit 5e2935e

File tree

5 files changed

+6
-3
lines changed

5 files changed

+6
-3
lines changed

app/graphql/item.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
@strawberry.experimental.pydantic.type(
1313
model=ItemModel,
14-
directives=[Key(fields="itemId")])
14+
directives=[Key(fields="itemId"), Key(fields="givenUrl")])
1515
class Item:
1616
item_id: str # This type is a 'str' and not an 'ID' in our graph.
17+
given_url: str # This type is a 'str' and not an 'ID' in our graph.
1718

1819
# a field from a different subgraph
1920
# see https://www.apollographql.com/docs/federation/entities-advanced/#contributing-computed-entity-fields

app/graphql/recommendation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ class Recommendation:
2020
feed_item_id: Optional[strawberry.ID] = strawberry.field(deprecation_reason="Use `id`")
2121
feed_id: auto
2222
item_id: strawberry.ID
23-
item: Item = strawberry.federation.field(shareable=True)
23+
item: Item = strawberry.federation
2424
rec_src: str
2525
publisher: auto

app/models/candidate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ class Candidate(BaseModel):
55
item_id: int
66
publisher: str
77
feed_id: Optional[int]
8+
url: str

app/models/item.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33

44
class ItemModel(BaseModel):
55
item_id: str
6+
given_url: str

app/models/recommendation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def candidate_dict_to_recommendation(candidate: dict):
5252
feed_id=candidate.get('feed_id'),
5353
publisher=candidate.get('publisher'),
5454
item_id=candidate.get('item_id'),
55-
item=ItemModel(item_id=candidate.get('item_id'))
55+
item=ItemModel(item_id=candidate.get('item_id'), url=candidate.get('url')),
5656
)
5757
recommendation.feed_item_id = recommendation.id
5858
return recommendation

0 commit comments

Comments
 (0)