这是indexloc提供的服务,不要输入任何密码
Skip to content

Specifying APIVersion with ShopifySharp.Extensions.DependencyInjection #1214

@nls-aarndt

Description

@nls-aarndt

I am trying to shift to usingShopifySharp.Extensions.DependencyInjection to register ShopifySharp dependecies, but I am having trouble figuring out how to specify the apiVersion.

I am currently using the GraphService

This is how I was previously registering IGraphService:

services.AddSingleton<IGraphService, GraphService>((provider) =>
{
    var config = provider.GetRequiredService<IOptions<ShopifyConfiguration>>().Value;
    return new GraphService(config.BaseUrl, config.AccessToken, apiVersion: "unstable");
});

This is my attempt through the DependencyIntjection package, attempting to utilize the LeakyBucketExecutionPolicy

services.AddShopifySharp<LeakyBucketExecutionPolicy>();

services.AddSingleton<IGraphService, GraphService>((provider) =>
{
    var factory = provider.GetRequiredService<IGraphServiceFactory>();
    var config = provider.GetRequiredService<IOptions<ShopifyConfiguration>>().Value;
    var credentials = new ShopifyApiCredentials(config.BaseUrl, config.AccessToken);

    // no option to set api version
    var service = factory.Create(credentials);
});

Is it possible to set the apiVersion through the DependencyInjection package?

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions