-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(ds): add discount_nodes as endpoint; add resolvers #40766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…tition_key resolvers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10 files reviewed, 2 comments
| data = [endpoint_config.incremental_field_resolver(row) for row in data if row.get("discount")] | ||
| if endpoint_config.partition_key_resolver: | ||
| data = [endpoint_config.partition_key_resolver(row) for row in data if row.get("discount")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: the hardcoded filter row.get("discount") makes resolvers non-reusable for other endpoints. if another endpoint needs resolvers in the future, this filter would incorrectly apply to it
| data = [endpoint_config.incremental_field_resolver(row) for row in data if row.get("discount")] | |
| if endpoint_config.partition_key_resolver: | |
| data = [endpoint_config.partition_key_resolver(row) for row in data if row.get("discount")] | |
| if endpoint_config.incremental_field_resolver: | |
| data = [endpoint_config.incremental_field_resolver(row) for row in data] | |
| if endpoint_config.partition_key_resolver: | |
| data = [endpoint_config.partition_key_resolver(row) for row in data] |
Prompt To Fix With AI
This is a comment left during a code review.
Path: posthog/temporal/data_imports/sources/shopify/shopify.py
Line: 103:105
Comment:
**style:** the hardcoded filter `row.get("discount")` makes resolvers non-reusable for other endpoints. if another endpoint needs resolvers in the future, this filter would incorrectly apply to it
```suggestion
if endpoint_config.incremental_field_resolver:
data = [endpoint_config.incremental_field_resolver(row) for row in data]
if endpoint_config.partition_key_resolver:
data = [endpoint_config.partition_key_resolver(row) for row in data]
```
How can I resolve this? If you propose a fix, please make it concise.|
|
||
| # NOTE: 250 is the max allowable query size for nested connections | ||
| DISCOUNT_NODES_QUERY = f""" | ||
| query PaginatedDiscountCodes($pageSize: Int!, $cursor: String, $query: String) {{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: query name PaginatedDiscountCodes doesn't match the endpoint name discountNodes
| query PaginatedDiscountCodes($pageSize: Int!, $cursor: String, $query: String) {{ | |
| query PaginatedDiscountNodes($pageSize: Int!, $cursor: String, $query: String) {{ |
Prompt To Fix With AI
This is a comment left during a code review.
Path: posthog/temporal/data_imports/sources/shopify/queries/discount_nodes.py
Line: 7:7
Comment:
**style:** query name `PaginatedDiscountCodes` doesn't match the endpoint name `discountNodes`
```suggestion
query PaginatedDiscountNodes($pageSize: Int!, $cursor: String, $query: String) {{
```
How can I resolve this? If you propose a fix, please make it concise.
Problem
tl;dr
i added resolvers that make endpoints which normally cant be incremental or partitioned by datetime able to be both of those things
longer version:
some shopify graphql endpoints implement interfaces where fileds like updatedAt and createdAt are present in the implementation but not on the immediately returned data. discountNodes is one such example. this PR adds discountNodes as an endpoint and adds "resolvers" that can safely pull data from within an interface implementation out to the objects top level scope for incremental update and partitioning purposes.
Changes
Add incremental field resolver and partition key resolver pure functions to the shopify endpoint config
How did you test this code?
Wrote additional unit tests for utils; ran locally to confirm that the endpoint syncs successfully.
Changelog: (features only) Is this feature complete?
No