【问题标题】:Drupal GraphQL - Query Single Entity from URLDrupal GraphQL - 从 URL 查询单个实体
【发布时间】:2018-09-05 19:49:38
【问题描述】:

是否可以使用 Url Alias (entityUrl.path) 获取文章(单个实体)?

我正在使用https://github.com/drupal-graphql/graphql

我可以对所有文章进行批量查询,然后过滤这些结果吗?

谢谢

query GetArticles {
  nodeQuery(filter: {conditions: [{field: "type", value: "article"}]}) {
    Articles: entities {
      entityId
      entityLabel
      entityUrl {
        path
        routed
      }
    }
  }
}

【问题讨论】:

    标签: graphql drupal-8


    【解决方案1】:

    想通了

    query ($path: String!) {
      route:route(path: $path) {
        ... on EntityCanonicalUrl {
          entity {
            ... on Node {
              nid
              entityLabel
              body{
                value
              }
            }
          }
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-11-22
      • 1970-01-01
      • 1970-01-01
      • 2019-10-26
      • 2021-04-26
      • 2019-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多