response->message() ?? 'Unauthorized'; } /** * @return array */ public function attributes(): array { return [ 'name' => $this->getName(), 'description' => $this->description(), 'baseType' => $this->baseType(), ]; } public function getName(): string { return $this->name; } abstract public function description(): string; /** * The arguments of the class resolve as customs class helper. * * @return Argument[] */ public function arguments(): array { $arguments = []; $baseType = $this->baseType(); if ($this instanceof EloquentPaginationQuery) { $arguments[] = new FirstArgument(); $arguments[] = new PageArgument(); } if ($baseType instanceof BaseType) { $arguments[] = FilterCriteria::getFilters($baseType)->map(fn (Filter $filter): array => $filter->getArguments())->flatten(); } if ($baseType instanceof BaseType && $this instanceof EloquentPaginationQuery) { $arguments[] = new SortArgument($baseType); } return Arr::flatten($arguments); } /** * Convert the rebing type to a GraphQL type. */ public function toType(): Type { return GraphQL::type($this->baseType()->getName()); } /** * The base return rebing type of the query. */ public function baseType(): ?BaseType { return null; } public function type(): Type { if (! $this->nullable) { if ($this->isList) { return Type::nonNull(Type::listOf(Type::nonNull($this->toType()))); } return Type::nonNull($this->toType()); } if ($this->isList) { return Type::listOf(Type::nonNull($this->toType())); } return $this->toType(); } }