首页 > 解决方案 > 有没有办法在 1 个查询中通过 id/pk/some 查找进行查询,而不是过滤所有节点并使用 id?

问题描述

https://github.com/graphql-python/graphene-django/issues/349 http://docs.graphene-python.org/projects/django/en/latest/tutorial-relay/

这会查询所有成分,然后使用上一个查询获取特定成分。这是中继/石墨烯中的正常设计模式还是可以在 1 个查询中完成?

query {
  allIngredients {
    edges {
      node {
        id,
        name
      }
    }
  }
}

query {
  # Graphene creates globally unique IDs for all objects.
  # You may need to copy this value from the results of the first query
  ingredient(id: "SW5ncmVkaWVudE5vZGU6MQ==") {
    name
  }
}

标签: djangographqlrelaygraphene-python

解决方案


推荐阅读