Where can I find the order.source_name in the Graphql API?

fedeb
Excursionist
18 1 5
Replies 12 (12)

Gregarican
Shopify Partner
1033 86 285

Try this:

# Get the last 10 orders
{
  orders(first: 10, reverse: true) {
    edges {
      node {
        id
        name
        publication {
          name
          app {
            title
          }
        }
      }
    }
  }
}
fedeb
Excursionist
18 1 5

@Gregarican 

 

I tried that and got:

 

"publication": {
"name": "Online Store",
"app": {
"title": "Online Store"
}
}
}

 

but the API REST, returns :

webposshopify_draft_orderiphone, and android.

 

How I can get this?
Its a bug from Graphql ? where I can report this??

Gregarican
Shopify Partner
1033 86 285

There are some noted differences between the REST API and the GraphQL API. While the GraphQL API is more standardized and powerful in terms of efficiency, it lacks a bit of the functionality of the REST API when it comes to the details. The devil and in the details after all, so there apparently are some disconnects. 

The Shopify staff monitor the forums, so I'm sure they could chime in here. @_JB any feedback?

fedeb
Excursionist
18 1 5

In Shopify documentation, blogs, forums, the Shopfy Stuff always enconruge developers to use GraphQL that will be the best option.
But still lack a lot of information...

I'm using Bulk Operation to get Order Shopify data, I need this information.

I can't refactor and discard GraphQL to API REST, it has limit like limits for request per second and information size data.

Gregarican
Shopify Partner
1033 86 285

So the GraphQL API will return the origination source for an order --- Shopify POS, Online Store, etc. But you are looking for even more granular specifics for each order then? I'm re-reading your earlier posts on this thread.

For example, you need to know that an order originated from the online store based on the customer using an iPhone? That is pretty granular. In those cases it might make more sense to use Google Analytics to cross-reference things.

fedeb
Excursionist
18 1 5

@Gregarican 


Shopify already has all this information.

I need this info but in the Graphql response.

https://xxxx/admin/orders/xxxx.json

API REST returns:

...
"client_details": {
"browser_ip": "xxxxx",
"accept_language": "en-us",
"user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1",
"session_hash": null,
"browser_width": 414,
"browser_height": 725
},
...
processing_method": "direct",
"checkout_id": xxxxx,
"source_name": "web",
"fulfillment_status": null,
....

Gregarican
Shopify Partner
1033 86 285

I get what you're saying. But if you have a goal in mind, you have to look at the available tools for the job. Unfortunately the solution to achieving your goal involves working with more than a single API resource. In this case, both the Shopify REST API and the Shopify GraphQL API. The Shopify staff monitor these forums, so any API enhancement requests, bug reports, etc. will get onto their radar. But if you need to develop a solution in the here and now, you will need to make some API requests using the REST API, while making other API requests using the GraphQL API. I have a few projects that bounce between both. The time it takes to research the forums, deliberate about options, and the like can be more than it takes to actually dig in and build the API queries that will do the job. 

Of course the REST API has rate limits and other limiting factors that come into play. But again, we are given tools to do the job. Some tools are sharper than others. Until the GraphQL has been fully built out to match the attribute depth of the REST API, it's the best tools we have!

MeasuredInc
Shopify Partner
14 0 1

We are having the exact issue with Shopify's GraphQL API.

Are there any recent updates regarding Order.source_name on Shopify's GraphQL API? 

 

Thanks

chriscoyne
Shopify Partner
7 0 2

hey did you get an answer to this? I have the same question.

ShopifyDevSup
Shopify Staff
1317 216 454

hi @chriscoyne , You can query the order.app in GraphQL to find the Application that created the order. Or query Orders and filter by 'sales_channel'. 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

srcb
Shopify Partner
10 0 2

@ShopifyDevSup I just wanted to make sure I get this correctly. What in the Rest API is called source_name, in GraphQL can be found under order.app.id (modified for GraphQL standardization), and when I want to filter orders for an app, I can use the sales_channel filter (using just the numerical part of the order.app.id)?

I find the filter documentation to be very lacking, it just lists a bunch of filters, but doesn't explain what they are supposed to match. Some are pretty self explanatory, such as name, gateway & updated_at, but some are really confusing, for example, how am I supposed to know what field sales_channel is filtering for?  I don't see any indication that it's supposed to match the order.app.id. Another example, I see a filter source_name, what is that supposed to match? It doesn't match the source_name in the REST API, and GraphQL doesn't have a field source_name, so what does it match? What field is it looking for? Better documentation would be appreciated, with perhaps a way to see examples.

ShopifyDevSup
Shopify Staff
1317 216 454

Hey @srcb - thanks for reaching back out, happy to clarify. You are correct that when it comes to the GQL equivalent of the REST "source_name" field, it would be the value of the app.id field under the order/orders object. Here's simple example for how you could query that object to poll some app IDs:

{
 orders(first: 100, reverse: true) {
   edges {
     node {
       app {
         id
         name
       }
     }
   }
 }
}

Then, let's say you find the app ID you want to filter for in order to find out which app/sales channel the order was created through. You could then run a query like this one to filter for those relevant orders (this query could always be simplified/expanded, but I just wanted to include some example info for clarity):

{
 orders(first: 1, reverse: true, query:"sales_channel:'580111'") {
   edges {
     node {
       app {
         id
         name
       }
       id
       createdAt
       channelInformation {
         channelId
         channelDefinition {
           handle
           channelName
         }
       }
     }
   }
 }
}
 

Here's the output response for the above:

{
 "data": {
   "orders": {
     "edges": [
       {
         "node": {
           "app": {
             "id": "gid://shopify/App/580111",
             "name": "Online Store"
           },
           "id": "gid://shopify/Order/5726565892402",
           "createdAt": "2023-12-28T18:57:20Z",
           "channelInformation": {
             "channelId": "gid://shopify/ChannelInformation/111005696306",
             "channelDefinition": {
               "handle": "web",
               "channelName": "Online Store"
             }
           }
         }
       }
     ]
   }
 }

 

Using the numerical ID for the app in the sales_channel filter should limit the GQL only to orders put through channel. I see what you mean about the documentation though - this could definitely be made more clear. I can't guarantee anything on my end here in terms of a fix/change to the documentation at the moment, but I will for sure pass along a note to our product team on your behalf. 

Hope this helps!

Al | Shopify Developer Support

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog