Using graphql to query model with 'foreign keys'

Hi @stanpanza , It’s hard without seeing how the structure of the data you have configured for articles, so going to use an example here for a model, that have a list of authors, where the structure is similar to this

   "modelWithList": [
      {
        "name": "onlly johnny",
        "data": {
          "authorsList": [
            {
              "author": {
                "@type": "@builder.io/core:Reference",
                "id": "edcaddd1a70f494ba1955704cd88ca4f",
                "model": "author"
              }
            }
          ]
        }
      },
      {
        "name": "all",
        "data": {
          "authorsList": [
            {
              "author": {
                "@type": "@builder.io/core:Reference",
                "id": "ba1fb5129adf4c379424d346666cc092",
                "model": "author"
              }
            },
            {
              "author": {
                "@type": "@builder.io/core:Reference",
                "id": "edcaddd1a70f494ba1955704cd88ca4f",
                "model": "author"
              }
            }
          ]
        }
      }
    ]

Where authorsList is a list of author model references, and a graphql query that look like this :

query($query: JSONObject!) {
  // includeRefs is optional and it means to populate references values
  modelWithList(query: $query, options: { includeRefs: true }) {
    name
    data {
      authorsList
    }
  }
}

and I want to find all entries that has reference to a specific ID within the authorsList array I can do:

{
  "query": {
    "data.authorsList.author.id": "ba1fb5129adf4c379424d346666cc092"
  }
}

If I wanted to query the content with authorsList that contain any value from a list of ids, or compose custom queries on the list elements, you can use here $elemMatch

{
  "query": {
    "data.authorsList": {
      "$elemMatch": {
        "author.id": {
          "$in": [
            "first-value",
            "some-other-value"
          ]
        }
      }
    }
  }
}

Hope this helps