name ?? Str::camel($this->column); } /** * Get the column of the field. */ public function getColumn(): string { return $this->column; } /** * The description of the field. */ public function description(): string { return ''; } /** * The type returned by the field. */ public function type(): Type { $baseType = $this->baseType(); $type = $baseType instanceof BaseType ? GraphQL::type($baseType->getName()) : $baseType; if (! $this->nullable) { return Type::nonNull($type); } return $type; } /** * The arguments of the type. * * @return Argument[] */ public function arguments(): array { return []; } /** * The args for the field. * * @return array> */ public function args(): array { return collect($this->arguments()) ->mapWithKeys(fn (Argument $argument) => [ $argument->name => [ 'name' => $argument->name, 'type' => $argument->getType(), ...(! is_null($argument->getDefaultValue()) ? ['defaultValue' => $argument->getDefaultValue()] : []), ], ]) ->toArray(); } /** * The type returned by the field. */ abstract public function baseType(): Type|BaseType; /** * Resolve the field. */ public function resolve($root, array $args, $context, ResolveInfo $resolveInfo): mixed { return Arr::get($root, $this->column); } }