This repository has been archived by the owner on Mar 29, 2020. It is now read-only.
Releases: nuwave/laravel-graphql-relay
Releases · nuwave/laravel-graphql-relay
v0.3.4: Merge pull request #25 from hosmelq/master
Use getKey method instead of id
v0.3.3: Merge pull request #21 from davidstoker/add-root-value
Allow for passing rootValue
v0.3.2
v0.3.1
v0.3.0: Merge pull request #10 from nuwave/develop
Merge develop branch
v0.2.0
v0.1.6
Dependency version bump
v0.1.5 dependency version bumped
Default resolver for connections
If no resolve method is set on a connection, the following function will be used:
function ($collection, array $args, ResolveInfo $info) use ($name) {
$items = [];
if ($collection instanceof Model) {
$items = $collection->getAttribute($name);
} else if (is_object($collection) && method_exists($collection, 'get')) {
$items = $collection->get($name);
} else if (is_array($collection) && isset($collection[$name])) {
$items = new Collection($collection[$name]);
}
if (isset($args['first'])) {
$total = $items->count();
$first = $args['first'];
$after = $this->decodeCursor($args);
$currentPage = $first && $after ? floor(($first + $after) / $first) : 1;
return new Paginator(
$items->slice($after)->take($first),
$total,
$first,
$currentPage
);
}
return new Paginator(
$items,
count($items),
count($items)
);
}
Added mutation test helper
Helper trait that allows you to easily test mutations:
<?php
use Nuwave\Relay\Traits\MutationTestTrait;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class CreateUserMutationTest extends TestCase
{
use DatabaseTransactions, MutationTestTrait;
/**
* @test
*/
public function itCanCreateANewUser()
{
$this->mutate('createUser', [
'firstName' => 'John',
'lastName' => 'Doe',
'email' => 'john.doe@example.com',
'password' => 'foobar',
'password_confirmation' => 'foobar'
])->seeJson([
'firstName' => 'John',
'lastName' => 'Doe'
]);
}
}