Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/FieldsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,6 @@ private function getFieldsByMethodAnnotations(
$methodName = $refMethod->getName();

if ($queryAnnotation instanceof Field) {
if (str_starts_with($methodName, 'set')) {
continue;
}
$for = $queryAnnotation->getFor();
if ($typeName && $for && ! in_array($typeName, $for)) {
continue;
Expand Down
11 changes: 11 additions & 0 deletions tests/FieldsBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
use TheCodingMachine\GraphQLite\Fixtures\TestTypeWithMagicProperty;
use TheCodingMachine\GraphQLite\Fixtures\TestTypeWithMagicPropertyType;
use TheCodingMachine\GraphQLite\Fixtures\TestTypeWithPrefetchMethods;
use TheCodingMachine\GraphQLite\Fixtures\TestTypeWithSetPrefix;
use TheCodingMachine\GraphQLite\Fixtures\TestTypeWithSourceFieldInterface;
use TheCodingMachine\GraphQLite\Fixtures\TestTypeWithSourceFieldInvalidParameterAnnotation;
use TheCodingMachine\GraphQLite\Mappers\CannotMapTypeException;
Expand Down Expand Up @@ -440,6 +441,16 @@ public function testSourceFieldIsId(): void
$this->assertInstanceOf(IDType::class, $fields['test']->getType()->getWrappedType());
}

public function testFieldWithSetPrefixPresence(): void
{
$queryProvider = $this->buildFieldsBuilder();
$fields = $queryProvider->getFields(new TestTypeWithSetPrefix());
$this->assertCount(2, $fields);

$this->assertSame('settings', $fields['settings']->name);
$this->assertSame('numberOfParameters', $fields['numberOfParameters']->name);
}

public function testFromSourceFieldsInterface(): void
{
$queryProvider = new FieldsBuilder(
Expand Down
24 changes: 24 additions & 0 deletions tests/Fixtures/TestTypeWithSetPrefix.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\GraphQLite\Fixtures;

use TheCodingMachine\GraphQLite\Annotations\Field;
use TheCodingMachine\GraphQLite\Annotations\Type;

#[Type(class: TestObject::class)]
class TestTypeWithSetPrefix
{
#[Field]
public function settings(): string
{
return 'settings';
}

#[Field(name: 'numberOfParameters')]
public function setOfParameters(): int
{
return 4;
}
}
Loading