Skip to content

Conversation

@andrewjmcgehee
Copy link
Contributor

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

@posthog-bot posthog-bot requested a review from a team October 31, 2025 23:02
Copy link
Contributor

@greptile-apps greptile-apps bot left a 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

Edit Code Review Agent Settings | Greptile

Comment on lines +103 to +105
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")]
Copy link
Contributor

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

Suggested change
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) {{
Copy link
Contributor

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

Suggested change
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants