Skip to content
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

source-shopify-native: new connector #2277

Merged
merged 3 commits into from
Jan 16, 2025
Merged

Conversation

Alex-Bair
Copy link
Member

@Alex-Bair Alex-Bair commented Jan 15, 2025

Description:

This is a native capture connector for Shopify leveraging their GraphQL API.

Using the GraphQL API is motivated by Shopify stating that their REST API (specifically the /products and /variants endpoints in the near-term) will be inaccessible soon. There are multiple differences between the REST and GraphQL schemas for equivalent resources, including:

  • snake_case vs. camelCase field names
  • renamed fields
  • different nesting of subresources

Due to these differences, compatibility with our existing source-shopify import was not a goal during development; we don't want our native connector to serve as a transformation layer to try and maintain compatibility with Shopify's REST API schemas.

This initial version of the connector only contains the product stream since that's the first one to supposedly stop working on 01FEB2025.

Important design decisions include:

  • Retrieving data via bulk query operations. This avoids the rate/complexity limits enforced on non-bulk queries & allows us to fetch significantly more fields and results than using non-bulk queries.
  • Introspection was not used to programmatically build queries since it would have been possible to get in an infinite loop due to circular GraphQL connections.
  • Abstracting bulk query execution into a graphql module within the connector. BulkJobManager handles executing bulk queries, and stream specific queries and result processing are located within individual files. This should make it a little easier to add more streams later; we'll just need to add the query and result processing logic for the specific stream, and we can use products.py as a template.

I've tested out what edge cases I can to ensure BulkJobManager works well, but I've left some info level logging to make monitoring easier as the connector begins being used. The logging can be tamped down to debug later as we tune & improve BulkJobManager.

Workflow steps:

(How does one use this feature, and how has it changed)

Documentation links affected:

Documentation should be created for source-shopify-native. It should specify what permissions are needed for the connector to work, especially since it needs the read_publications permission that our imported source-shopify connector does not need.

Notes for reviewers:

Tested on a local stack with a few Shopify accounts. Confirmed:

  • bulk query jobs are submitted and products results are processed appropriately.
  • OAuth works with an OAuth app I created within my dev Shopify account. It didn't work when I tried with our prod OAuth app credentials, but I'm pretty sure that's because http://localhost:3000 isn't whitelisted as a valid redirect URI for our OAuth app.

This change is Reviewable

@Alex-Bair Alex-Bair marked this pull request as ready for review January 15, 2025 23:01
@Alex-Bair Alex-Bair linked an issue Jan 15, 2025 that may be closed by this pull request
@Alex-Bair Alex-Bair added the change:planned This is a planned change label Jan 15, 2025
Copy link
Member

@williamhbaker williamhbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments

@Alex-Bair Alex-Bair force-pushed the bair/source-shopify-native branch from 95c80ea to 504f538 Compare January 16, 2025 15:47
This is a native capture connector for Shopify leveraging their GraphQL
API.

Using the GraphQL API is motivated by Shopify stating that their REST
API (specifically the `/products` and `/variants` endpoints in the
near-term) will be inaccessible soon. There are multiple differences
between the REST and GraphQL schemas for equivalent resources, including:
- snake_case vs. camelCase field names
- renamed fields
- different nesting of subresources

Due to these differences, compatibility with our existing `source-shopify`
import was not a goal during development; we don't want our native
connector to serve as a transformation layer to try and maintain
compatibility with Shopify's REST API schemas.

This initial version of the connector only contains the `product` stream
since that's the first one to supposedly stop working on 01FEB2025.

Important design decisions include:
- Retrieving data via bulk query operations. This avoids the
  rate/complexity limits enforced on non-bulk queries & allows us to
  fetch significantly more fields and results than using non-bulk queries.
- Introspection was not used to programmatically build queries since it
  would have been possible to get in an infinite loop due to circular
  GraphQL connections.
- Abstracting bulk query execution into a `graphql` module within the
  connector. `BulkJobManager` handles executing bulk queries, and stream
  specific queries and result processing are located within individual
  files. This should make it a little easier to add more streams later;
  we'll just need to add the query and result processing logic for the
  specific stream, and `products.py` can serve as a template.

I've tested out what edge cases I can to ensure `BulkJobManager` works
well, but I've left some info level logging to make monitoring easier
as the connector begins being used. The logging can be tamped down to
debug later as we tune & improve `BulkJobManager`.
Some fields that seem like they'd be useful for troubleshooting or identifying Shopify resources are added to `products`.
@Alex-Bair Alex-Bair force-pushed the bair/source-shopify-native branch from 504f538 to b23bce7 Compare January 16, 2025 16:21
Copy link
Member

@williamhbaker williamhbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Alex-Bair Alex-Bair merged commit dacc97e into main Jan 16, 2025
73 of 82 checks passed
@Alex-Bair Alex-Bair deleted the bair/source-shopify-native branch January 16, 2025 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:planned This is a planned change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

source-shopify: Upgrade to GraphQL
2 participants