获取rootValue的父级

时间:2020-04-15 12:53:57

标签: laravel-lighthouse

我目前正在使用自定义字段解析器来计算商品的价格。但是,我需要能够获取已解析的rootValue的父级。那可能吗?。 我正在谈论的这是继承人:

    /**
         * Return a list of categories
         *
         * @param null $rootValue
         * @param array $args
         * @param GraphQLContext $context
         * @param ResolveInfo $resolveInfo
         * @return mixed
         */
        public function resolvePrice($rootValue, array $args, GraphQLContext $context, ResolveInfo $resolveInfo)
        {
            $customer_id = $rootValue->parentValue->parentValue->customer_id; // I need to be able to do this.
        }

这是图ql

query {
  shopping_cart_header(id: 4) {
    id
    shopping_cart_lines(first: 10, page: 1) {
      data {
        quantity
        inv_mast {
          product_type
          item_desc
          price
        }
      }
    }
  }
}

非常感谢您的帮助。

0 个答案:

没有答案