Search code examples
graphqlcraftcms

CraftQL - Unable to find tags field in matrix field


I've got a matrix field with a "Tags" field inside:

MAtrix field definition.

I'm using CraftQL to fetch all fields within this entry and generally it works really well, except for that Tags field.

When I run the below query in the CraftQL console in the admin panel, theBasicsIndustries returns an array of tags, as expected.

query StoryQuery($slug: String!) {
    entry(siteId: 2, slug: $slug) {
      ... on StoriesStory {
        id
        contentBlock {
          ... on ContentBlockTheBasics {
            __typename
            id
            theBasicsName                

            theBasicsIndustries {
              id
              title
            }
          }       
        }
      }
    }
  }

Produces:

{
  "data": {
    "entry": {
      "id": 26,
      "contentBlock": [
        {
          "__typename": "ContentBlockTheBasics",
          "id": "112",
          "theBasicsName": "Some name",
          "theBasicsIndustries": [
            {
              "id": 108,
              "title": "Hospitality"
            },
            {
              "id": 109,
              "title": "Technology"
            }
          ]
        }
      ]
    }
  }
}

However when I run the same exact query through the API, it returns

Cannot query field "theBasicsIndustries" on type "ContentBlockTheBasics".

  1. Is there a special to query for the tags? I tried running the same query via Postman and the same error shows up.
  2. Why does it work in the admin console, and not in the API?

Thank you!


Solution

  • This is rather silly, but the problem was caused by a missing permission in CraftQL settings!

    The token I was using didn't have the Query any tag access.

    enter image description here