Я пытаюсь получить данные из моего GraphQL, но он возвращает эту ошибку:
{
"message": "Cannot declare class App\\GraphQL\\Mutations\\AcceptBooking, because the name is already in use",
"exception": "Symfony\\Component\\Debug\\Exception\\FatalErrorException",
"file": "/Users/stevenvaneck/projects/hihiguide/app/Http/GraphQL/Mutations/AcceptBooking.php",
"line": 14,
"trace": []
}
AcceptBooking. php
<?php
namespace App\GraphQL\Mutations;
use Auth;
use App\Booking;
use App\Http\Controllers\Email\MailType;
use GraphQL\Type\Definition\ResolveInfo;
use App\Http\Controllers\Email\MailController;
use App\Jobs\Mail\Traveler\SendNewAvailableMail;
use App\Jobs\SMS\SendNewAvailableSMS;
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;
class AcceptBooking
{
/**
* Return a value for the field.
*
* @param null $rootValue Usually contains the result returned from the parent field. In this case, it is always `null`.
* @param array $args The arguments that were passed into the field.
* @param GraphQLContext|null $context Arbitrary data that is shared between all fields of a single query.
* @param ResolveInfo $resolveInfo Information about the query itself, such as the execution state, the field name, path to the field from the root, and more.
*
* @return mixed
*/
public function resolve($rootValue, array $args, GraphQLContext $context = null, ResolveInfo $resolveInfo)
{
//my code
}
}
Если я изменю имя класса что-то случайное снова говорит, что новое имя, которое я дал, используется.
В моем schema.graphql
type Mutation {
acceptBooking(data: AcceptInput): String @middleware(checks: ["auth:api"]) @field(resolver: "App\\Http\\GraphQL\\Mutations\\AcceptBooking@resolve")
declineBooking(data: DeclineInput): String @middleware(checks: ["auth:api"]) @field(resolver: "App\\Http\\GraphQL\\Mutations\\DeclineBooking@resolve")
}
Я использую Lighthouse- php в Laravel проект.