Getting Comment Event Attachment

djdy1892
New Member
2 0 0

I am having trouble accessing order comment attachments via GraphQL.

https://shopify.dev/docs/admin-api/graphql/reference/object/commentevent/commenteventattachment

 

I get as far as getting that comments are present, but not their details, such as attachments.

query {
  currentAppInstallation {
    id
  }

  order(id: "gid://shopify/Order/#"){
        id
        createdAt
        hasTimelineComment
   
        events(first: 10) {
          edges {
            node {
              __typename
              id
              message
            }
      }
    }
  }
}

Any advice on how to get commenteventattachment? Thank you.

0 Likes
SBD_
Shopify Staff
Shopify Staff
1081 146 193

Hey @djdy1892 

 

Are you able to capture a request ID from the response headers?

0 Likes
scaphan
New Member
3 0 0

I am having the exact same problem.

 

Did you resolve this? Can anyone help?

0 Likes
scaphan
New Member
3 0 0

For the record I resolved this as follows:

get the timeline for a given order like this:

 

{
  order(id:"gid://shopify/Order/1949776576599"){
    customer{
      firstName
      displayName
    }
    email
    events (first:100){
      edges{
        node{
          message
          id
          __typename
        }
      }
    }
  }
}

 

then grab each comment ID you want and use this call to get the attachments:

 

{
 node(id: "gid:\/\/shopify\/CommentEvent\/74802414190768"){
  id
  __typename
  ... on CommentEvent {
    message
    subject{
      hasTimelineComment
      __typename
      id
    }
    rawMessage
    attachments{
      fileExtension
      id
      url
      name
      image{
        id
        originalSrc
        transformedSrc
      }
    }
  }
}
}

 not sure what the ... on does but it works!

Apologies if there is a more elegant and efficient way.

0 Likes