1

当我向 graphQL 解析器添加一些自定义字段时,我没有得到任何答案

我的查询是:


<?php

namespace App\GraphQL\Queries;

use GraphQL\Type\Definition\ResolveInfo;
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;

class ComplexQuery
{
    public function __invoke($rootValue, array $args, GraphQLContext $context, ResolveInfo $resolveInfo)
    {
        return [ 'complexResult'=> 33]
        // I tried this but I had the same result
        // return (object) [ 'complexResult'=> 33]
    }
}

在查询中,我定义了下一个模式:

type Query {
  complexQuery: complexTypeQuery
}

type complexTypeQuery {
  complexResult: Int
}

提前致谢!

4

1 回答 1

1

Try removing the semicolon in the type complexTypeQuery: { line.

Update: Also you arn't specifying the field resolver in the query definition.

type Query {
  complexQuery: complexTypeQuery @field(resolver: "ComplexQuery")
}
于 2020-07-06T21:09:00.170 回答