Releases: nozzlegear/ShopifySharp
ShopifySharp 6.24.0
Removal of deprecated GraphRequest properties
This release of ShopifySharp removes two properties on the GraphRequest
class that were deprecated back in early January:
Removed | Replacement | Old type | New type |
---|---|---|---|
GraphRequest.query |
GraphRequest.Query |
string | string |
GraphRequest.variables |
GraphRequest.Variables |
object | Dictionary<string, object> |
Migrating to the new properties is pretty simple, you'll just need to refactor the variables from an anonymous object type to a dictionary:
// Old, wack:
var graphRequest = new GraphRequest
{
query = "...",
variables = new { foo = "bar", baz = 5 }
};
// New, dope:
var graphRequest = new GraphRequest
{
Query = "...",
Variables = new Dictionary<string, object>
{
{ "foo", "bar" },
{ "baz", 5 }
}
};
Thanks to @mikejamescalvert for the pull request!
New Contributors
- @mikejamescalvert made their first contribution in #1183
Full Changelog: ShopifySharp/6.23.0...ShopifySharp/6.24.0
❤️ How to support ShopifySharp
If you find ShopifySharp useful, please consider contributing to the project! If you'd like contribute financially, you can do so by sponsoring the author here on Github, or by purchasing a copy of The Shopify Development Handbook on Gumroad – an updated version using GraphQL is coming soon!.
ShopifySharp 6.23.0
Improved support for Online (per-user) access tokens
This release of ShopifySharp improves support for Shopify's "Online" access tokens (alternately referred to as "per-user" access tokens in Shopify's documentation) by adding a new AuthorizationAccessMode
enum for use with the ShopifyOauthUtility.BuildAuthorizationUrl
method. In addition, a new OnlineAccess
property has been added to the AuthorizationResult
type, which will be populated by Shopify if you send the user through Shopify's OAuth login flow using the AuthorizationAccessMode.Online
mode.
When you use the Online access mode, the access token granted will be scoped to the permissions of the shop user. That means if you're using a mix of Offline access tokens and Online access tokens for the same shop, the Online access token may not have the same permissions as the one granted by the Offline access token. Additionally, the Online access token will expire after 24 hours (timespan subject to change at the mercy of almighty Shopify).
User | Shop role | Access mode | Permissions granted |
---|---|---|---|
John | Owner | Online | ["read-orders", "write-orders"] |
Alice | Staff | Online | ["read-orders", "write-orders"] |
Bob | Staff | Online | ["read-orders"] |
Jane | Collaborator | Online | [] |
– | – | Offline | ["read-orders", "write-orders"] |
Here's a quick example showcasing the new Online access mode support:
```cs
var shopifyOauthUtility = new ShopifyOauthUtility();
// Step 1: Send the user to Shopify's OAuth page using the Online access mode
var redirectUri = shopifyOauthUtility.BuildAuthorizationUrl(new AuthorizationUrlOptions
{
Scopes = ["read-orders"],
ClientId = "your-shopify-client-id",
State = "some-random-state-token",
ShopDomain = "example.myshopify.com",
AuthorizationAccessMode = AuthorizationAccessMode.Online,
RedirectUrl = "yourapp.example.com/oauth/callback"
});
// ...
// Step 2: Exchange the temporary code for an access token like usual, but this time the `AuthorizationResult`
// will have a populated `OnlineAccess` object that's contextualized to the shop user.
var authorizationResult = await shopifyOauthUtility.AuthorizeAsync(new AuthorizeOptions
{
Code = Request.QueryString["code"],
ShopDomain = "example.myshopify.com",
ClientId = "your-shopify-client-id",
ClientSecret = "your-shopify-client-secret",
});
if (authorizationResult.IsOnlineAccess)
{
Console.WriteLine("OnlineAccess expires in: {0}", authorizationResult.OnlineAccess.ExpiresIn);
// The shop user may not have the same scopes as the shop owner!
Console.WriteLine("Shop user has these scopes: {0}", authorizationResult.OnlineAccess.AssociatedUserScopes);
// Additional information about the shop user can be found in authorizationresult.OnlineAccess.AssociatedUser
DoSomethingWithAssociatedUser(authorizationResult.OnlineAccess.AssociatedUser);
}
Other changes
Two other changes have been included in this release:
- Coinciding with support for the new AuthorizationAccessMode enum, the two
IShopifyOauthUtility.BuildAuthorizationUrl
methods that tookIEnumerable<string> grants
parameters have been deprecated in favor ofIShopifyOauthUtility.BuildAuthorizationurl(AuthorizationUrlOptions)
.
- The goal here is to improve future maintainability and backwards compatibility, as it's easier to add/remove/deprecate properties from a record than it is to modify the parameters of a method without introducing breaking changes.
- Added
IJsonElement.ValueEquals(xyz)
andIJsonElement.ValueIsNullOrWhiteSpaceString
methods.
Full Changelog: ShopifySharp/6.22.2...ShopifySharp/6.23.0
❤️ How to support ShopifySharp
If you find ShopifySharp useful, please consider contributing to the project! If you'd like contribute financially, you can do so by sponsoring the author here on Github, or by purchasing a copy of The Shopify Development Handbook on Gumroad – an updated version using GraphQL is coming soon!.
ShopifySharp 6.22.2
🐛 Fixin' bugs 💥
ShopifySharp v6.22.2 is now available on Nuget! This release contains bugfixes for several annoying System.Text.Json deserialization bugs that would rear their ugly heads when ShopifySharp deserialized certain response values using the GraphService. Here's the full list of fixes in this release:
- It was discovered that Shopify uses two different json structures for
GraphErrorExtensions.Value
, and a bug has been fixed where the second, previously unknown structure would cause the GraphService to throw aShopifyJsonParseException
. #1149 - Fixed an issue where any non-string value in the
GraphError.Path
value would cause the GraphService to throw aShopifyJsonParseException
. #1152 - Fixed an issue with the
ObjectDictionaryConverter
where nested json objects would erroneously be returned as JsonElement values rather than their intended .NET clr types. #1162
Full Changelog: ShopifySharp/6.22.1...ShopifySharp/6.22.2
❤️ How to support ShopifySharp
If you find ShopifySharp useful, please consider contributing to the project! If you'd like contribute financially, you can do so by sponsoring the author here on Github, or by purchasing a copy of The Shopify Development Handbook on Gumroad – an updated version using GraphQL is coming soon!.
ShopifySharp 6.22.1
Summary
This release of ShopifySharp contains a small fix for a bug that caused the GraphService to throw a ShopifyJsonParseException
when parsing a json response containing an errors.extensions
object that didn't match the expected json structure. Parsing rules for errors and extensions have been relaxed. This bug only affected .NET Framework users.
Full Changelog: ShopifySharp/6.22.0...ShopifySharp/6.22.1
Don't forget to check out the previous release for more info on migrating your Shopify apps to Shopify's GraphQL Product API before February 1st (or April 1st for custom apps), and then head over to ShopifySharp's wiki page for an in-depth guide to using the GraphService!
How to support ShopifySharp
If you find ShopifySharp useful, please consider contributing to the project! If you'd like contribute financially, you can do so by sponsoring the author here on Github, or by purchasing a copy of The Shopify Development Handbook on Gumroad.
ShopifySharp 6.22.0
Summary
This is a big new release for ShopifySharp with lots of changes inside! If you're using the ProductService or Products API, make sure you've started your migration over to Shopify's GraphQL Products API using the GraphService – Shopify has deprecated the REST API for products1 and product-related-things. All public apps are required to migrate to the GraphQL product API by February 1st, 2025, and all custom apps are required to migrate by April 1st, 2025. 2 Read up on this release, grab the latest version of ShopifySharp and then head over to the wiki page where you can find a guide on using ShopifySharp's GraphService to write GraphQL queries and mutations, with examples featuring the product API.
In line with those requirements, this release of ShopifySharp has many changes aimed at improving the GraphQL experience for developers. From standardizing the methods on ShopifySharp's GraphService class to make it less confusing, to adding baked-in graphql syntax highlighting and intellisense with minimal setup, the experience with the GraphService compared to even just one release should be miles ahead.
Our goal is to make the experience of writing graph queries in ShopifySharp and C# in general as painless as possible. I have a lot more improvements still planned, so I'd love to hear your feedback on how things feel in this release and how they can still be improved.
What's Changed
Here's a grand overview of everything that's new or changed in ShopifySharp 6.22.0:
- Fixed a content disposal bug that affected .NET Framework in #1130.
- Many previous GraphService and IGraphService methods were deprecated, and all methods have now standardized on
GraphService.PostAsync(GraphRequest)
,GraphService.PostAsync<T>(GraphRequest)
andGraphService.PostAsync(GraphRequest, Type)
in #1051. - The GraphService's error handling was updated and standardized to consistently throws
ShopifyGraphErrorsException
andShopifyGraphUserErrorsException
when errors are parsed from the response from Shopify in #1127. - Added an
IHttpContentSerializer
andGraphContentSerializer
in #1122.- The intent is to open these up and make them injectable for fine-grained control of how content is serialized before it's sent to Shopify.
- Added an
IJsonSerializer
andSystemJsonSerializer
in #1123.- Related to the previous, the intent here is to open these up as well and make them injectable for fine-grained control of how content is serialized/deserialized/parsed.
- There will also be a NewtonsoftJsonSerializer.
- The ProductService, ProductVariantService, ProductImageService, ProductListingService, along with their related interfaces and factories, were all deprecated in #1128.
- Regenerated the GraphQL entities in the ShopifySharp.GraphQL namespace in #1115.
- Dependencies were updated in #1121.
- Added documentation for using the GraphService in #1126.
Full Changelog: ShopifySharp/6.21.0...ShopifySharp/6.22.0
How to support ShopifySharp
If you find ShopifySharp useful, please consider contributing to the project! If you'd rather contribute financially, you can do so by sponsoring the author here on Github, or by purchasing a copy of The Shopify Development Handbook on Gumroad.
-
Shopify has actually deprecated the entire REST API, but they've deprecated the Products API ahead of everything else. We're expected to migrate everything over to the GraphQL API eventually! ↩
-
Product API migration dates: https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model ↩
ShopifySharp.Extensions.DependencyInjection 1.8.0
Summary
ShopifySharp.Extensions.DependencyInjection version 1.8.0 is now available on Nuget! This version primarily contains under-the-hood enhancements for the latest version of ShopifySharp v6.22.0, which itself has massive changes to the GraphService and json serialization.
In addition to those under-the-hood updates for supporting ShopifySharp, this release also paves the way for an update I'm working on to bring even more service injection into ShopifySharp. The plan is to help you inject things like HttpClientFactory, HttpClient, json serializers, and more. Check this board for more details.
What's changed
- This package now requires ShopifySharp >= v6.22.0 to install.
- .NET Framework 6.0 was dropped as a target framework.
- An
IServiceProvider
is now passed to all ShopifySharp service factories to resolve dependencies. This is now the preferred constructor method for the factories. - ShopifySharp's service factories themselves now construct the ShopifySharp service classes using the
new (ShopifyApiCredentials credentials)
constructor. Previously, they used thenew (string shopDomain, string accessToken)
constructor.
Full Changelog: 1.7.0...ShopifySharp.Extensions.DependencyInjection/1.8.0
How to support ShopifySharp
If you find ShopifySharp useful, please consider contributing to the project! If you'd like contribute financially, you can do so by sponsoring the author here on Github, or by purchasing a copy of The Shopify Development Handbook on Gumroad.
ShopifySharp 6.18.0
Summary
ShopifySharp v6.18.0 is now available on Nuget! This release updates our target Shopify API version to 2024-07. You can upgrade ShopifySharp using the dotnet CLI – dotnet add package shopifysharp --version 6.18.0
– or with your IDE's package manager UI. Once you upgrade ShopifySharp, don't forget to upgrade your Shopify webhook API version in the Partner dashboard to match.
What's changed
- All service classes now use API version 2024-07, as noted above.
- All GraphQL entities in the
ShopifySharp.GraphQL
namespace have been regenerated based on Shopify's 2024-07 GraphQL schema. - Added a new
Transaction.AdjustmentReason
property. - Added new
DeliveryMethod.ServiceCode
,DeliveryMethod.SourceReference
,DeliveryMethod.BrandedPromise
andDeliveryMethod.AdditionalInformation
properties. - Deprecated the
CountryService
,CountryServiceFactory
and related interfaces. Shopify has deprecated the REST API's Country endpoint, and they recommend developers migrate to the Storefront GraphQL API as an alternative. - Removed deprecated
Order.ProcessingMethod
property. - Removed deprecated
FulfillmentServiceEntity.FulfillmentOrdersOptIn
property. Fulfillment Orders are now the only processing method for fulfillment services and fulfilling orders in general, so there is no more concept of "opting in" to fulfillment orders. - Removed deprecated
ShopifyException
http properties. If you used. these properties, you should be able to switch all of yourcatch (ShopifyException ex) where (ex.StatusCode)
to(ShopifyHttpException ex) where (ex.StatusCode)
. - Moved
ShopifyHttpException
into theShopifySharp
namespace for consistency. - Added a default exception message for
ShopifyExponentialRetryCanceledException
.
These changes should only affect you if you've created your own class that extends one of ShopifySharp's services, or if you've created a custom IRequestExecutionPolicy
:
- Removed deprecated
RequestResult.Response
property. If you need access to the response status code, you should be able to useRequestResult.StatusCode
instead. - Removed deprecated
ShopifyService.PrepareRequest
method. This was replaced withShopifyService.BuildRequestUri
. - Removed deprecated
ShopifyService.BuildShopUri
method. This was replaced withIShopifyDomainUtility.BuildShopDomainUri
. - Removed deprecated
CloneableRequestMessage.Clone
method. This was replaced withCloneableRequestMessage.CloneAsync
.
Full Changelog: ShopifySharp/6.17.0...ShopifySharp/6.18.0
How to support ShopifySharp
If you find ShopifySharp useful, please consider contributing to the project! If you'd rather contribute financially, you can do so by sponsoring the author here on Github, or by purchasing a copy of The Shopify Development Handbook on Gumroad.
ShopifySharp 6.16.1
Summary
ShopifySharp v6.16.1 is a small release that addresses a potential memory leak bug with undisposed cloneable request messages inside the new ExponentialRetryPolicy
. Depending on the way you've configured the policy's options, the policy could eventually run your application out of memory as it held onto each request and woudld never let new ones attack.
What's Changed
- fix: Dispose cloned request messages in
ExponentialRetryPolicy
by @nozzlegear in #1069
Full Changelog: ShopifySharp/6.16.0...ShopifySharp/6.16.1
How to support ShopifySharp
If you find ShopifySharp useful, please consider contributing to the project! If you'd rather contribute financially, you can do so by sponsoring the author here on Github, or by purchasing a copy of The Shopify Development Handbook on Gumroad.
ShopifySharp 6.16.0
Summary
This release introduces a new request execution policy for ShopifySharp called ExponentialRetryPolicy
! As the name suggests, this policy is responsible for making requests to Shopify's API, and then introducing an exponential delay between the last failure and the next time it tries to send the request. The exponential delay is on a per-request basis, so there's no attempt to be "smart" in this policy or to perform any sort of lookup on the access token being used or the leaky bucket status.
You can configure the new policy using the ExponentialRetryPolicyOptions
class:
var policyOptions = new ExponentialRetryPolicyOptions
{
InitialBackoffInMillseconds = 50,
MaximumDelayBetweenRetries = TimeSpan.FromSeconds(1),
MaximumTriesBeforeRequestCancellation = null,
MaximumDelayBeforeRequestCancellation = TimeSpan.FromSeconds(5)
};
Note that MaximumTriesBeforeRequestCancellation
and MaximumDelayBeforeRequestCancellation
are both nullalbe, but one of them is in fact required and will be validated when the policy is constructed.
Alongside the new policy, this release also adds the RequestResult.StatusCode
property, which should make it a simple matter to grab the response's status code in custom IRequestExecutionPolicy
"middleware" without relying on the deprecated (and soon to be removed) HttpPRequestMessage
object.
Finally, there's a small change that most won't noticed in this pull request unless you've got your own custom IRequestExecutionPolicy
. The return result types of RequestResult.GetRestBucketState
and RequestResult.GetGraphQLBucketState
were changed to be nullable. This does not actually change the underlying implementation – the methods could always return null, the types were simply updated to reflect that fact.
Changelog
- Add RequestResult.StatusCode property by @nozzlegear in #1063
- Make RequestResult bucket state return types nullable, plus misc refactoring by @nozzlegear in #1066
- Feature: Retry policy with exponential delay by @nozzlegear in #1065
Full Changelog: ShopifySharp/6.15.1...ShopifySharp/6.16.0
How to support ShopifySharp
If you find ShopifySharp useful, please consider contributing to the project! If you'd rather contribute financially, you can do so by sponsoring the author here on Github, or by purchasing a copy of The Shopify Development Handbook on Gumroad.
ShopifySharp.Extensions.DependencyInjection 1.6.0
Summary
ShopifySharp.Extensions.DependencyInjection 1.6.0 adds support for ShopifySharp's new ExponentialRetryPolicy
. Since this is the first policy that requires or supports any kind of configuration, the package has been updated to add defaults for those options to DI when the policy has been added but the options have not. You can override those defaults by supplying your own options:
var policyOptions = new ExponentialRetryPolicyOptions
{
InitialBackoffInMillseconds = 50,
MaximumDelayBetweenRetries = TimeSpan.FromSeconds(1),
MaximumTriesBeforeRequestCancellation = null,
MaximumDelayBeforeRequestCancellation = TimeSpan.FromSeconds(5)
};
services.AddSingleton(policyOptions);
services.AddShopifySharp<ExponentialRetryPolicy>();
If you don't supply any configuration options, the package will use ExponentialRetryPolicyOptions.Default
instead.
Changelog
- Feature: Retry policy with exponential delay by @nozzlegear in #1065
Full Changelog: ShopifySharp.Extensions.DependencyInjection/1.5.0...ShopifySharp.Extensions.DependencyInjection/1.6.0
How to support ShopifySharp
If you find ShopifySharp useful, please consider contributing to the project! If you'd rather contribute financially, you can do so by sponsoring the author here on Github, or by purchasing a copy of The Shopify Development Handbook on Gumroad.