Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Querying orders by channel or channel ID

Solved

Querying orders by channel or channel ID

afdev
Visitor
2 0 0

I am attempting to write a graphQL query that will query orders by channel or channel ID as listed in the docs as accepted query strings: https://shopify.dev/docs/api/admin-graphql/2023-04/queries/orders

However, for a query that contains a channel ID, I am receiving an internal server error:

 

{
    "errors": [
        {
            "message": "Internal error. Looks like something went wrong on our end.\nRequest ID: e9a946f3-5a7c-4817-9582-7341d7d77269 (include this in support requests).",
            "extensions": {
                "code": "INTERNAL_SERVER_ERROR",
                "requestId": "e9a946f3-5a7c-4817-9582-7341d7d77269"
            }
        }
    ]
}

 

This is the attempted query:

 

  orders(first: 10, query: "channel_id:'gid://shopify/ChannelInformation/[REDACTED]'" ) {
    edges {
      node {
          channelInformation {
              id,
              channelId
          }
          app {
              name
          }
      }
    }
  }

 

 I have tried various different combinations of channel ID including without the underscore and in camelcase instead. This does not return an error but does return any results. Furthermore, if I put a space between "chanel_id" and the ID, it also does not return an error but does not return any results. My app does have permission to read channels and I know I am querying by a valid channel ID from the channelInformation object.  

 

I have also tried to query by "channel" as specified in the docs but I am unsure what this means by channel. The name? The ID? The only channel information on an order is "channelInformation" which is an object with various other attributes. Would anybody know the mores specific string this query parameter means by "channel"?

 

Thanks. 

Accepted Solution (1)

SBD_
Shopify Staff
1831 273 421

This is an accepted solution.

Hey @afdev 

 

Thanks for the request ID. I had success by replacing the GID with just the ID:

 

{
  customers(first: 10, query: "email:...") {
    edges {
      node {
        orders(
          first: 10
          query: "channel_id:'9212.......'"
        ) {
          edges {
            node {
              channelInformation {
                id
                channelId
              }
              app {
                name
              }
            }
          }
        }
      }
    }
  }
}

 

Let me know if you get stuck.

 

Scott

Scott | Developer Advocate @ Shopify 

View solution in original post

Reply 1 (1)

SBD_
Shopify Staff
1831 273 421

This is an accepted solution.

Hey @afdev 

 

Thanks for the request ID. I had success by replacing the GID with just the ID:

 

{
  customers(first: 10, query: "email:...") {
    edges {
      node {
        orders(
          first: 10
          query: "channel_id:'9212.......'"
        ) {
          edges {
            node {
              channelInformation {
                id
                channelId
              }
              app {
                name
              }
            }
          }
        }
      }
    }
  }
}

 

Let me know if you get stuck.

 

Scott

Scott | Developer Advocate @ Shopify