The request is:
orders (first: 20, query: “id:>1” ) {
edges {
node {
sourceName
Postman results:
“data”: {
“orders”: {
“edges”: [
{
“node”: {
“sourceName”: “web”,
.NET results
{
“errors”: [
{
“message”: “Field ‘sourceName’ doesn’t exist on type ‘Order’”,
I am querying many more fields with the .NET code without issue.
This data is critical to my code when selecting for WEB versus POS for our ERP integration.
Thanks for your help.
Hi Jerome,
If you test this query on the Shopify GraphiQL app , do you see the same error?
This is the code in the app:
{
orders(first: 1, query: "id:5898946543866") {
edges {
node {
id
createdAt
updatedAt
name
email
tags
paymentGatewayNames
sourceIdentifier
sourceName
totalTipReceivedSet {
shopMoney {
amount
currencyCode
}
}
taxLines {
priceSet {
shopMoney {
amount
currencyCode
}
}
title
rate
ratePercentage
}
shippingLine {
carrierIdentifier
code
deliveryCategory
title
}
currencyCode
subtotalPriceSet {
shopMoney {
amount
currencyCode
}
}
totalShippingPrice
totalPrice
cartDiscountAmountSet {
shopMoney {
amount
currencyCode
}
}
currentCartDiscountAmountSet {
shopMoney {
amount
currencyCode
}
}
currentSubtotalPriceSet {
shopMoney {
amount
currencyCode
}
}
discountCodes
discountApplications(first: 100) {
edges {
node {
allocationMethod
targetSelection
targetType
}
}
}
shippingAddress {
firstName
lastName
name
address1
address2
phone
city
zip
province
country
company
latitude
longitude
countryCodeV2
provinceCode
}
billingAddress {
firstName
lastName
name
address1
address2
phone
city
zip
province
country
company
latitude
longitude
countryCodeV2
provinceCode
}
lineItems(first: 100) {
edges {
node {
id
name
title
sku
quantity
customAttributes {
key
value
}
discountAllocations {
allocatedAmountSet {
shopMoney {
amount
currencyCode
}
}
}
totalDiscountSet {
shopMoney {
amount
currencyCode
}
}
discountedUnitPriceSet {
shopMoney {
amount
currencyCode
}
}
originalUnitPriceSet {
shopMoney {
amount
currencyCode
}
}
}
}
}
}
}
}
}
The .net is identical save for the variables:
orders(first: {0}, query: "id{1}") {
edges {
node {
id
createdAt
updatedAt
name
email
tags
paymentGatewayNames
sourceIdentifier
sourceName
totalTipReceivedSet {
shopMoney {
amount
currencyCode
}
}
taxLines {
priceSet {
shopMoney {
amount
currencyCode
}
}
title
rate
ratePercentage
}
shippingLine {
carrierIdentifier
code
deliveryCategory
title
}
currencyCode
subtotalPriceSet {
shopMoney {
amount
currencyCode
}
}
totalShippingPrice
totalPrice
cartDiscountAmountSet {
shopMoney {
amount
currencyCode
}
}
currentCartDiscountAmountSet {
shopMoney {
amount
currencyCode
}
}
currentSubtotalPriceSet {
shopMoney {
amount
currencyCode
}
}
discountCodes
discountApplications(first: 100) {
edges {
node {
allocationMethod
targetSelection
targetType
}
}
}
shippingAddress {
firstName
lastName
name
address1
address2
phone
city
zip
province
country
company
latitude
longitude
countryCodeV2
provinceCode
}
billingAddress {
firstName
lastName
name
address1
address2
phone
city
zip
province
country
company
latitude
longitude
countryCodeV2
provinceCode
}
lineItems(first: 100) {
edges {
node {
id
name
title
sku
quantity
customAttributes {
key
value
}
discountAllocations {
allocatedAmountSet {
shopMoney {
amount
currencyCode
}
}
}
totalDiscountSet {
shopMoney {
amount
currencyCode
}
}
discountedUnitPriceSet {
shopMoney {
amount
currencyCode
}
}
originalUnitPriceSet {
shopMoney {
amount
currencyCode
}
}
}
}
}
}
}
}
}
The error code is:
{
"errors": [
{
"message": "Field 'sourceName' doesn't exist on type 'Order'",
"locations": [
{
"line": 25,
"column": 9
}
],
"path": [
"query",
"orders",
"edges",
"node",
"sourceName"
],
"extensions": {
"code": "undefinedField",
"typeName": "Order",
"fieldName": "sourceName"
}
}
]
}
I am using C#, in Visual Studio 2022 - current version. I have created a few other queries in our migration project, and I have not found issues.
Thanks for your help.
My best guess is that you’re calling different versions of the GraphQL Admin API.
While sourceName
is available in the latest version , it doesn’t appear to be available in older versions such as 2024-01 .
What’s the API url you’re calling from each method?
Seems my guess was wrong as you’re using the latest stable version. I can’t spot anything else that may be an issue unfortunately.
I am continually digging. I suspect a small discrepancy between queries.
Thanks for your help.
BTW, I’m using the GraphQL.Client NuGet package in VS 2022 to interact with the API and haven’t had any issues with it.
Unfortunately I don’t have any code to quickly test querying the orders
, else I’d see if the same issue happened for me. All my code is working with fulfillmentOrders
.
I installed GraphQL.Client, but I am not using it… Thanks for reminding me. I will try.
Can you share some code?
Looking at our logs, one recent request I see from 2024-10-30T15:10:31 UTC
has two issues:
Path requested was /admin/api/2024-01/graphql.json
so API version 2024-01
was requested and served, which doesn’t have sourceName
as mentioned above.
There is a missing :
in the orders query
expression
- orders(first: 25, query: "id5898864132346") {
+ orders(first: 25, query: "id:5898864132346") {
Thanks. I see the errors.
The queries I am using are stored in SQL Server and I need to revisit them all for accuracy. The Version was stored for the legacy API and I changed them all to oct 2024.
I really appreciate your fast response. We are planning to migrate over 15 stores by Dec 31 and the back integration with our ERP must work as before.
Regards.
Jerome_Boyer:
Can you share some code?
No problem, but I have a lot of library code in play so it’s hard to extract meaningful snippets, so they might not be the best examples to work from…
Example mutation code snippet:
var request = new GraphQLRequest
{
Query = @"mutation fulfillmentOrderAcceptFulfillmentRequest($id: ID!, $message: String) {
fulfillmentOrderAcceptFulfillmentRequest(id: $id, message: $message) {
fulfillmentOrder {
id
}
userErrors {
field
message
}
}
}",
Variables = new
{
id = Constants.FulfillmentOrderIdPrefix + fulfillmentOrderId,
message = ConstrainFulfillmentMessageSize($"Fulfillment imported as order: {importedAsId}")
}
};
_log.LogDebug("GraphQL - Query: {Query}; Variables: {Variables}", request.Query, JsonSerializer.Serialize(request.Variables));
var graphQLClient = GetGraphQLHttpClient();
var response =await graphQLClient.SendMutationAsync<FulfillmentOrderAcceptFulfillmentResponse>(request);
Query code snippet:
private readonly string FulFillmentOrderGraphQlRequest = $@"
{{
id
createdAt
fulfillAt
fulfillBy
requestStatus
status
updatedAt
deliveryMethod {{
methodType
}}
assignedLocation {{
name
}}
destination {{
id
firstName
lastName
company
address1
address2
city
province
zip
countryCode
phone
email
}}
lineItems (first:{FulfillmentOrderLineItemsPageSize}) {{
edges {{
node {{
id
sku
totalQuantity
productTitle
variantTitle
}}
}}
}}
merchantRequests (first:{FulfillmentOrderMerchantRequestsPageSize}) {{
edges {{
node {{
sentAt
message
}}
}}
}}
order {{
displayFulfillmentStatus
name
note
confirmed
createdAt
updatedAt
cancelledAt
shippingAddress {{
id
name
firstName
lastName
company
address1
address2
city
province
provinceCode
zip
country
countryCodeV2
phone
latitude
longitude
coordinatesValidated
formatted
formattedArea
}}
shippingLine {{
title
}}
fulfillments {{
id
}}
}}
}}";
var graphQLClient = GetGraphQLHttpClient();
var request = new GraphQLRequest
{
Query = $@"
{{
fulfillmentOrder(id:""{Constants.FulfillmentOrderIdPrefix}{fulfillmentOrderId}"") {FulFillmentOrderGraphQlRequest}
}}"
};
_log.LogDebug("GraphQL query: {Query}", request.Query);
var response = await SendQueryAsync<FulfillmentOrderQueryResponse>(graphQLClient, request);
if (applyThrottleWait) await ThrottleWaitAsync(response.Extensions);
Thanks a lot.
I will explore this avenue soon.
Using plain C# is not that bad either.
Regards.
Thanks for your help. The query has been updated and the aoi version set to 2024-10 – everything worked fine.
Hello Gavin,
There are about 10 stores in our organization that get their
fulfillments from third party app, like Shipstation or ChitChat. I
have to back fill the ERP system with the data from Shopify – using
our internal ERP to ChitChats/Shipstation only works for items shipped
from our warehouse. and we have few to deal with using other third
party apps.
Ideally, I would have a Shopify Graph query returning all fulfilment
by Created date. And then I can match these rows with our internal
records based on order ID.
Our internal fulfillment is not in sequence of order date. Order 12345
could be fulfilled before 11000. Unless I do a one by one match,
querying the API for each ERP order to see its fulfillment data, I
cannot get a query using a bulk approach, by returning all fulfillment
by created date with -displayStatus:‘FULFILLED’. The key is always the
orderID.One by one may take up to 20 minutes or more as we have
sometimes a 1000 orders fulfilled in one day.
I understand that the fulfillment data is order based. Using this:
query FulfillmentDataByOrder { orders( first: 10 query:
“-displayFulfillmentStatus:FULFILLED createdAt:<‘2024-10-10’”) { nodes
{ id createdAt displayFulfillmentStatus fulfillments { createdAt
updatedAt id name service { callbackUrl handle } status trackingInfo {
company number url } fulfillmentLineItems(first: 100) { nodes {
lineItem { sku quantity id title } } } } } } }
THIS: query: “-displayFulfillmentStatus:FULFILLED createdAt:<‘2024-10-10’”)
Returns:
“id”: “gid://shopify/Order/5665654210631”,
“createdAt”: “2024-10-25T13:02:40Z”,
“displayFulfillmentStatus”: “UNFULFILLED”,
“fulfillments”:
Am I missing a beat or is the createdAt not recognized as a query parameter?
Thanks for your insight!
Regards.