Filtering by a content relationship in a group

Hello, I am trying to filter my Thing by Widget.

When I run the following search, I get no results

query Query($id: ID!) {
  allPrismicThing(filter: {data: {widgets: {elemMatch: {widget: {id: {eq: $id}}}}}}) {
    edges {
      node {
        id
      }
    }
  }
}

But if I do this, it works:

query Query($uid: String!) {
  allPrismicThing(filter: {data: {widgets: {elemMatch: {widget: {uid: {eq: $uid}}}}}}) {
    edges {
      node {
        id
      }
    }
  }
}

I'm running this to get the id and uid, so I know the values are correct.

query Query {
  allPrismicWidget {
    nodes {
      id
      uid
    }
  }
}

I also notice, I need to set the type for id to ID or it yells, although it's a String when I do this:

query Query ($id: String) {
  allPrismicWidget(filter: {id: {eq: $id}}) {
    nodes {
      id
      uid
    }
  }

Any help would be appreciated

Hello @prismic16

Welcome back to the Prismic community, and thanks for reaching out to us.

You need to set the id value as String. For example:

query Query($id: String) {
  allPrismicThing(filter: {data: {widgets: {elemMatch: {widget: {id: {eq: $id}}}}}}) {
    edges {
      node {
        id
      }
    }
  }
}

Give this a try and let me know.

Thanks,
Priyanka

That didn't work either. But playing around, I found out that in this case the id is actually the prismicId and that using that it worked.

Hello Justin,

I am glad that you have solved the issue. Could you please share your working code with us?

Thanks,
Priyanka