JCoder.Shopify4Net.GraphQLAPI 3.2606.1

dotnet add package JCoder.Shopify4Net.GraphQLAPI --version 3.2606.1
                    
NuGet\Install-Package JCoder.Shopify4Net.GraphQLAPI -Version 3.2606.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JCoder.Shopify4Net.GraphQLAPI" Version="3.2606.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JCoder.Shopify4Net.GraphQLAPI" Version="3.2606.1" />
                    
Directory.Packages.props
<PackageReference Include="JCoder.Shopify4Net.GraphQLAPI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add JCoder.Shopify4Net.GraphQLAPI --version 3.2606.1
                    
#r "nuget: JCoder.Shopify4Net.GraphQLAPI, 3.2606.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package JCoder.Shopify4Net.GraphQLAPI@3.2606.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=JCoder.Shopify4Net.GraphQLAPI&version=3.2606.1
                    
Install as a Cake Addin
#tool nuget:?package=JCoder.Shopify4Net.GraphQLAPI&version=3.2606.1
                    
Install as a Cake Tool

JCoder.Shopify4Net.GraphQLAPI

[TOC]

一.架构说明

JCoder.Shopify4Net.GraphQLAPI
语言 C#
协议 MIT
.Net框架 .Net Standard2.1; .Net Framework 4.7.2; .Net 6; .Net 8; .Net 10;
简述 A simple library for Shopify.(一款简易版的用于Shopify的.Net库;基于 Shopify Admin GraphQL API 实现 IShopifyApi,支持订单查询、按订单号/ID 取单、更新订单发货状态与备注。)

1.1 引用类库

无第三方依赖(内部基于 JCoder.Network 发送请求,JCoder.Text4Net 处理 JSON)。

1.2 相关类库

| 相关类库 | 说明 | | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | | JCoder.Shopify4Net | Shopify 抽象接口、配置、凭证与通用数据实体(通过 ProjectReference 引用)。 | | JCoder | JCoder 基础工具库(通过 ProjectReference 引用)。 | | JCoder.Shopify4Net.RESTAPI | 基于 Shopify Admin REST API 的 IShopifyApi 实现。 |

获取方式

  1. 版本要求:>=3.2605.1
  2. 以版本3.2605.1为例
获取方式 描述
Package Manager Install-Package JCoder.Shopify4Net.GraphQLAPI -Version 3.2605.1
.Net CLI dotnet add package JCoder.Shopify4Net.GraphQLAPI --version 3.2605.1
PackageReference <PackageReference Include="JCoder.Shopify4Net.GraphQLAPI" Version="3.2605.1" />
Paket CLI paket add JCoder.Shopify4Net.GraphQLAPI --version 3.2605.1
Script&Interactive #r "nuget: JCoder.Shopify4Net.GraphQLAPI, 3.2605.1"
Cake // Install JCoder.Shopify4Net.GraphQLAPI as a Cake Addin<br/>#addin nuget:?package=JCoder.Shopify4Net.GraphQLAPI&version=3.2605.1<br/><br/>// Install JCoder.Shopify4Net.GraphQLAPI as a Cake Tool<br/>#tool nuget:?package=JCoder.Shopify4Net.GraphQLAPI&version=3.2605.1

使用说明

1. 初始化并配置应用

using JCoder.Shopify4Net;
using JCoder.Shopify4Net.GraphQLAPI;

var _api = new ShopifyGraphQLApi();
_api.Config.ClientID = "your-client-id";
_api.Config.ClientSecret = "your-client-secret";
_api.Config.AppVersion = "2024-10";
_api.Config.Scopes = "read_orders,write_orders";
_api.Config.RedirectUri = "https://yourapp.com/shopify/callback";

2. 注册店铺凭证并查询订单

using JCoder.Shopify4Net;
using JCoder.Shopify4Net.GraphQLAPI;

const string _storeDomain = "your-store.myshopify.com";

// 注册店铺 access token(店铺安装 OAuth 完成后获得)
_api.AddStoreCredential(_storeDomain, new ShopifyStoreCodeCredential(_storeDomain, "shpat_xxxxxxxx"));

// 按订单号列表批量查询订单
var _orders = await _api.GetOrdersByNumbersAsync(_storeDomain, new List<string> { "1001", "1002" });
foreach (var _order in _orders)
{
    // _order.ID / _order.Name / _order.Customer / _order.LineItems
}

// 按订单 ID 查询单个订单
ShopifyOrder _one = await _api.GetOrderByIdAsync(_storeDomain, "gid://shopify/Order/1234567890");

3. 更新订单发货状态与备注

using JCoder.Shopify4Net;
using JCoder.Shopify4Net.GraphQLAPI;

// 更新订单发货状态
// 说明:Shopify 的 displayFulfillmentStatus 是派生状态,orderUpdate 不支持直接设置。
// 本库仅支持 FULFILLED(已发货):通过 fulfillmentCreate 为订单的全部 fulfillment order 创建发货记录实现,
// 需要 write_merchant_managed_fulfillment_orders / write_assigned_fulfillment_orders 权限;
// 其余状态(UNFULFILLED 等)会抛出 NotSupportedException。
await _api.UpdateOrderFulfillmentStatusAsync(_storeDomain,
    "gid://shopify/Order/1234567890",
    ShopifyOrderDisplayFulfillmentStatus.FULFILLED);

// 更新订单备注
await _api.UpdateOrderNoteAsync(_storeDomain, "gid://shopify/Order/1234567890", "已发货");

// 更新订单自定义备注属性(对应官方 OrderInput.customAttributes,键为 key/value)
// 注意:传入的字典会覆盖订单现有的全部自定义属性
await _api.UpdateOrderNoteAttributesAsync(_storeDomain, "gid://shopify/Order/1234567890",
    new Dictionary<string, string> { ["warehouse"] = "HZ-01" });

4. 错误处理

GraphQL 响应中包含 errors 时(查询/变更字段不存在、无权限等),本库会抛出 ShopifyGraphQLException(含原始响应 ResponseJson);店铺未注册令牌、未配置 AppVersion 时抛出 InvalidOperationException,便于快速定位配置问题。

主要类与接口

类型 名称 类型 说明
类 ShopifyGraphQLApi 类 IShopifyApi 的 GraphQL 实现,内部调用 /admin/api/{version}/graphql.json。
类 GraphQLResponse<T> 类 GraphQL 响应包装(Data/Errors)。

实例使用

  1. 参考JCoder.Shopify4Net.GraphQLAPI
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.2606.1 60 10/6/2026
3.2605.1 156 6/5/2026
3.2604.1 137 6/4/2026
3.2603.2 126 6/3/2026
3.2603.1 125 6/3/2026

Please contact Jackie by QQ 1378071853 or E-mail JackieLaw-dev@outlook.com;