0

I have 5 different content types and I've added content / nodes. I'm using graphQL to fetch the data, however in 1 of the content types the data is not being returned. This is the latest content type I've added, so I can query data from all 4 other content types and get the data I expect without any problems using fragments.

My query for the new content type is simple.

{
  nodeQuery {
    entities {
      ...on NodeGlobalContent {
        title
        body {
          value
        }
      }
    }
  }
}

The empty result is the following.

{
  "data": {
    "nodeQuery": {
      "entities": [
        {},
        {},
        {},
        {},
        {},
        {},
        {},
        {},
        {},
        {}
      ]
    }
  }
}

If I query the node by ID, I get the following data.

query {
  nodeById(id: "20") {
    entityLabel
    entityBundle
  }
}

{
  "data": {
    "nodeById": {
      "entityLabel": "test",
      "entityBundle": "global_content"
    }
  }
}

Why can't I retrieve the data using a fragment?

1 Answer 1

0

The answer is to filter by content type:

{
  nodeQuery(
    filter: {
      conditions:[
        {operator: IN, field: "type", value: ["global_content"]},
      ]
    }
  ) {
    entities {
      ...on NodeGlobalContent {
        title
        body {
          value
        }
      }
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.