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

Add GraphQL service classes with pre-generated methods matching Shopify's queries and mutations #1137

@nozzlegear

Description

@nozzlegear

The idea here would be to create a second ShopifySharp package that builds off of and extends the base ShopifySharp package with extra niceties, kind of like the current ShopifySharp.Extensions.DependencyInjection adds DI extensions that aren't included in ShopifySharp itself.

In this case, the hypothetical package would be called something like ShopifySharp.Graph.GeneratedServices (name not final), and it would contain a litany of service classes that line up more or less with the current REST services in ShopifySharp. However, instead of methods matching the REST API endpoints, the methods in these classes would match up with the queries and mutations in Shopify's GraphQL API.

So, for example, the package would contain a ProductService class that implements the following interface:

namespace ShopifySharp.Graph.GeneratedServices;

public interface IProductService
{
    public async Task<GraphResult<Product>> Product(...)
    public async Task<GraphResult<Product>> ProductByHandle(...)
    public async Task<GraphResult<Product>> ProductByIdentifier(...)
    public async Task<GraphResult<Product>> ProductDuplicateJob(...)
    public async Task<GraphResult<IReadOnlyList<Product>> Products(...)
    public async Task<GraphResult<int> ProductsCount(...)
    public async Task<GraphResult<ProductChangeStatusResult>> ProductChangeStatus(...)
    public async Task<GraphResult<ProductCreateResult>> ProductCreate(...)
    public async Task<GraphResult<ProductDeleteResult>> ProductDelete(...)
    public async Task<GraphResult<ProductUpdateResult>> ProductUpdate(...)
    // ...
    // and many more product operations on
}

These methods would largely be generated automatically via source generator, and a Github Action could be scheduled to scan for changes to the GraphQL schema every [day|week] to regenerate the classes and push a new update to Nuget (after review).

This is just pseudo-code so there are a lot of actual implementation questions that are unanswered here, but I'd love to hear feedback about this. Is this something you'd find useful? If so, let me know! And don't forget to check #1132 and #1072 as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementexperimentalDeals with experimental features or changes that may not be published in ShopifySharp itselfgraphqlnew feature

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions