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

Allow api version overrides #1104

Merged
merged 6 commits into from
Jan 24, 2023
Merged

Allow api version overrides #1104

merged 6 commits into from
Jan 24, 2023

Conversation

ewalk153
Copy link
Member

@ewalk153 ewalk153 commented Jan 21, 2023

Description

Same feature need as Shopify/shopify-api-js#660 in the js client.

In order to develop again unstable features, it's important to be able to make some requests against the unstable version. Furthermore, it's helpful to be able to adopt the latest version of the ApiVersion per client while migrating versions.

This approach adds an optional parameter to the client for both graphql and rest implementations.

Shopify employees need this to layer on experimental features.

The expected outcome of this PR is to allow developers to experiment with new APIs while making most requests against a long term stable api version.

We may introduce an option to override per query in the future.

How has this been tested?

There is an automated test to confirm this has the desired behavior.

Checklist:

  • My commit message follow the pattern described in here
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the project documentation.
  • I have added a changelog line.

This optional param allow the default value inherited from Context to
be overridden on a per-query basis.
@ewalk153
Copy link
Member Author

ewalk153 commented Jan 21, 2023

If we align on this approach, I’ll update the release notes.

Changelog and docs are now up to date.

@ewalk153 ewalk153 changed the title Allow api version override in Graphql query Allow api version overrides Jan 23, 2023
This matches the approach taken the js client and will serve more
use cases than on the query.
@@ -45,12 +45,21 @@ def test_path_starting_at_admin_overrides_default
assert_equal(response_headers.to_h { |k, v| [k, [v]] }, response.headers)
end

def test_api_version_can_be_overrriden
@api_version = "2022-07"
Copy link
Member Author

Choose a reason for hiding this comment

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

Using an instance variable was expedient here. We can always rewrite this as an argument to run_test.

Copy link
Contributor

@mkevinosullivan mkevinosullivan left a comment

Choose a reason for hiding this comment

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

Some nits w.r.t. docs.

Also added some suggestions to log a debug message if the version is being overridden (informational for dev), or to log a debug message if it's being overridden by the same value as in Context (i.e., when it's unnecessary) ... aligns with Node library

docs/usage/graphql.md Outdated Show resolved Hide resolved
docs/usage/graphql_storefront.md Outdated Show resolved Hide resolved
lib/shopify_api/clients/rest/admin.rb Outdated Show resolved Hide resolved
lib/shopify_api/clients/graphql/client.rb Show resolved Hide resolved
@mkevinosullivan
Copy link
Contributor

mkevinosullivan commented Jan 23, 2023

Hmm, just noticed that the Node client has the debug messaging for Storefront too ... i.e., it may need to be a level higher than in my suggestions.

- add debug logging when the override is a NOOP
- improve documentation instructions

Co-authored-by: Kevin O'Sullivan <56687600+mkevinosullivan@users.noreply.github.com>
We should not render log output to $stdout in tests.
@@ -152,6 +152,7 @@ def test_send_a_warning_if_log_level_is_invalid
scope: [],
is_private: false,
is_embedded: true,
logger: ::Logger.new(T.let(StringIO.new, StringIO)),
Copy link
Member Author

@ewalk153 ewalk153 Jan 24, 2023

Choose a reason for hiding this comment

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

Redirect logs to a StringIO to quiet the minitest output. In the future, we can assign the StringIO to an instance variable before passing it in, and check its output to verify logging messages.

@ewalk153 ewalk153 merged commit ca9cad2 into main Jan 24, 2023
@ewalk153 ewalk153 deleted the ew-add-api-version-argument branch January 24, 2023 14:34
@shopify-shipit shopify-shipit bot temporarily deployed to rubygems July 11, 2023 18:25 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants