Skip to content

Commit

Permalink
Integration tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Carlino committed Jan 17, 2021
1 parent a174be8 commit 3f5c5d6
Show file tree
Hide file tree
Showing 7 changed files with 321 additions and 22 deletions.
7 changes: 6 additions & 1 deletion src/Schema/DataObject/FieldAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,12 @@ private function parsePath($subject, array $path)
$aggregateFunction
));
}
return call_user_func_array([$subject, $aggregateFunction], [$aggregateColumn]);
if (method_exists($subject, $aggregateFunction)) {
return call_user_func_array([$subject, $aggregateFunction], [$aggregateColumn]);
}

return null;

}

$singleton = DataObject::singleton($subject->dataClass());
Expand Down
1 change: 1 addition & 0 deletions src/Schema/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ public function save(): void
$this->addType($modelType);
}


$this->types[self::QUERY_TYPE] = $this->queryType;
if ($this->mutationType->exists()) {
$this->types[self::MUTATION_TYPE] = $this->mutationType;
Expand Down
36 changes: 34 additions & 2 deletions tests/Fake/IntegrationTestResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,28 @@

namespace SilverStripe\GraphQL\Tests\Fake;

use SilverStripe\GraphQL\Schema\Plugin\PaginationPlugin;

class IntegrationTestResolver
{
public static function resolveReadMyTypes($obj, $args = [])
{
return [
['field1' => 'foo', 'field2' => 2],
['field1' => 'bar', 'field2' => 3],
['field1' => 'foo', 'field2' => 2, 'field3' => 3],
['field1' => 'bar', 'field2' => 3, 'field3' => 3],
];
}

public static function resolveMyTypeField3($obj, $args = [])
{
$arg = $args['MyArg'] ?? null;
if ($arg) {
return 'arg';
}

return 'no arg';
}

public static function resolveReadMyTypesAgain()
{
return [
Expand All @@ -20,4 +32,24 @@ public static function resolveReadMyTypesAgain()
];
}

public static function lotsOfMyTypes($obj, $args = [])
{
return array_map(function ($num) {
return ['field1' => 'field1-' . $num];
}, range(1, 100));
}

public static function testPaginate($maxLimit)
{
return function ($list, $args) use ($maxLimit) {
$limit = min(($args['limit'] ?? 10), $maxLimit);
$offset = $args['offset'] ?? 0;
return PaginationPlugin::createPaginationResult(
count($list),
array_slice($list, $offset, $limit),
$limit,
$offset
);
};
}
}
Loading

0 comments on commit 3f5c5d6

Please sign in to comment.