Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #722 from B77Mills/updateNativeXAdvertiserStories
Browse files Browse the repository at this point in the history
Update to allow for querying by externalId
  • Loading branch information
brandonbk authored Jun 16, 2023
2 parents 87c356e + 8facdbf commit 2e671c0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/marko-web-native-x/components/marko.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"<marko-web-native-x-story-advertiser-related-stories>": {
"template": "./story/advertiser-related-stories.marko",
"@advertiser-id": "string",
"@external-id": "string",
"@publisher-id": "string",
"@exclude-story-ids": "array"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import buildQuery from "../../apollo/graphql/queries/related-stories";

$ const { req, nativeX } = out.global;

$ const { advertiserId, publisherId, excludeStoryIds } = input;
$ const { advertiserId, externalId, publisherId, excludeStoryIds } = input;
$ const args = {
config: nativeX,
advertiserId,
externalId,
...(publisherId && { publisherId }),
...(excludeStoryIds && { excludeStoryIds }),
};
Expand All @@ -19,6 +20,7 @@ $ const args = {
$ const getStories = async ({
config,
advertiserId,
externalId,
publisherId,
excludeStoryIds,
pagination,
Expand All @@ -27,19 +29,19 @@ $ const getStories = async ({
const { data } = await config.client.query({
query: buildQuery(queryFragment),
variables: {
input: { advertiserId, publisherId, excludeStoryIds },
input: { advertiserId, externalId, publisherId, excludeStoryIds },
...(pagination && { pagination }),
},
});
if (!data || !data.advertiserStories) return { nodes: [], pageInfo: {} };
const { pageInfo } = data.advertiserStories;
const nodes = data.advertiserStories.edges
.map(edge => (edge && edge.node ? edge.node : null))
.filter(c => c);
return { nodes, pageInfo };
};

<if(nativeX && advertiserId)>
<if(nativeX && (externalId|| advertiserId))>
<marko-web-resolve|{ resolved }| promise=getStories(args)>
<${input.renderBody} nodes=resolved.nodes pageInfo=resolved.pageInfo />
</marko-web-resolve>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = gql`
advertiser {
id
name
externalId
logo {
...NativeXImageFragment
}
Expand Down

0 comments on commit 2e671c0

Please sign in to comment.