See Sanity in action 👀 Join us for a live product demo + Q&A →

Troubleshooting phantom duplicates in GraphQL queries

4 replies
Last updated: Feb 4, 2023
hi all, anyone experienced phantom duplicates coming from graphql queries? for this query, I’m getting duplicates that don’t appear in the search in sanity studio. I don’t see anything in the query that could cause this and I’m not sure where to look next to troubleshoot this issue. Any pointers much appreciated! Thank you
  artists:allArtist(sort: [{ firstName: ASC }]){
    category
      featuredImage {
        alt
        asset {
          id: _id
          url
        }
      }
      firstName
      lastName
      slug {
        current
      }
  }
Feb 3, 2023, 10:41 PM
Are you making an authenticated request? If so, the duplicates are likely drafts.
Feb 3, 2023, 10:59 PM
user M
thank you! it looks like they are drafts. I would like to rewrite the query so that it filters out artists with id with ‘draft’, but looks like the field ‘allArtist’ doesn’t accept ‘filter’ as an argument. Could you point me in the right direction for how to fix this?
Feb 4, 2023, 1:20 AM
Hi
user A
. Could you please give this format a try, if you haven’t already? (Sorry I can’t link directly to the right example—it’s the third query block down from this link.):

query {
  allArtist(sort: [{ firstName: ASC }], where: {_: {is_draft: false}}) {
    ...
  }
}
Feb 4, 2023, 1:38 AM
thank you
user A
for relieving me of my headache! that format works perfectly 🙏
Feb 4, 2023, 3:19 AM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Categorized in