Skip to content

Fixing n+1 relations problem #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
60cdd3f
ignore PhpStorm IDE files
lorado Aug 5, 2018
9ec1416
improve guessing relations
lorado Aug 5, 2018
4c11459
fix errors
lorado Aug 6, 2018
718de93
define Paginable interface for identifying those transformers
lorado Aug 6, 2018
870de54
ListTransformer implements now Paginable interface
lorado Aug 6, 2018
bffe998
rework, how ListTransformer is identified
lorado Aug 6, 2018
f694792
extend DB structure for tests. Tests are still the same
lorado Aug 8, 2018
1051554
sync tables and model definitions
lorado Aug 8, 2018
53db424
rework how relations are identified (much cleaner and correct way)
lorado Aug 8, 2018
1453da4
add missing author parameter to PostDefinition
lorado Aug 8, 2018
171c290
define unit tests for eager loading relations
lorado Aug 8, 2018
035b470
copy-paste travis config
lorado Aug 8, 2018
13cdf22
delete unused imports
lorado Aug 8, 2018
a9beecc
refactor code, so phpmd don't blame on me (CouplingBetweenObjects)
lorado Aug 8, 2018
02cb7e9
calling function recursive make sense only, if relations are found
lorado Aug 8, 2018
88ceb91
save changes after php-cs-fixer
lorado Aug 8, 2018
9088301
remove unnecessary $app variable
lorado Aug 23, 2018
c9fe50e
define fiels selection depth as constant
lorado Aug 24, 2018
68901b2
move relations guessing to static in GraphQL class (will be reused)
lorado Aug 24, 2018
7703678
guess relations also for custom fields
lorado Aug 24, 2018
8bd4965
extend custom query, add test for eager loading in custom queries
lorado Aug 24, 2018
daf6927
add doc to test-query
lorado Aug 24, 2018
06097b4
remove array_filter(), as I see no reason in using it...
lorado Aug 24, 2018
c3bbc1a
extend readme
lorado Aug 24, 2018
55c3c00
fix code styling
lorado Aug 24, 2018
4af8f80
fetch fields ONLY, if returned type is an object
lorado Sep 3, 2018
83b94ea
add new test for fetching simple string from graphql
lorado Sep 3, 2018
fe7fd5e
add authorize check for fields, default is true. update readme
lorado Sep 3, 2018
31cb88b
add tests for authorize checking (test - unauthorized error gets thrown)
lorado Sep 3, 2018
e2a0261
fix definition of method
lorado Sep 3, 2018
dcc86aa
Merge branch 'master' into bug/26
cmizzi Sep 10, 2018
a92e22c
fix(transformers): fix bad merge
cmizzi Sep 10, 2018
12024dd
Merge branch 'master' into bug/26
lorado Sep 10, 2018
7d085f7
fix returned type in docs
lorado Sep 10, 2018
60928bb
adopt EloquentTransformer to fix n+1 problem (at least on read data)
lorado Sep 10, 2018
e227585
fix for linters
lorado Sep 10, 2018
4b52290
add readme for authorization
lorado Sep 10, 2018
5845e35
Merge remote-tracking branch 'origin/bug/26' into bug/26
lorado Sep 10, 2018
8a8eb19
remove unused reflect
lorado Sep 11, 2018
63f6abd
update readme
lorado Sep 11, 2018
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
Prev Previous commit
Next Next commit
add new test for fetching simple string from graphql
this test was implemented, as I found a bug in my last implementation. So I decided to create a test for this case
  • Loading branch information
lorado committed Sep 3, 2018
commit 83b94ea7e5b7e0eaae0ade72c3f160c624ef1722
16 changes: 16 additions & 0 deletions tests/GraphQL/Query/SimpleString.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace StudioNet\GraphQL\Tests\GraphQL\Query;

use StudioNet\GraphQL\Definition\Type;
use StudioNet\GraphQL\Support\Definition\Query;

class SimpleString extends Query {
public function getRelatedType() {
return Type::string();
}

public function getResolver() {
return 'You got this!';
}
}
26 changes: 26 additions & 0 deletions tests/GraphQLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use GraphQL\Type\Definition\ObjectType;
use StudioNet\GraphQL\GraphQL;
use StudioNet\GraphQL\Tests\Entity;
use StudioNet\GraphQL\Tests\GraphQL\Query\SimpleString;
use StudioNet\GraphQL\Tests\GraphQL\Query\Viewer;

/**
Expand Down Expand Up @@ -130,6 +131,31 @@ public function testCustomQuery() {
});
}

/**
* Test simple string query
*
* @return void
*/
public function testSimpleStringQuery() {
factory(Entity\User::class)->create();

$this->registerAllDefinitions([
'query' => [
SimpleString::class
]
]);

$this->specify('tests simple string query (SimpleString)', function () {
$query = 'query { simplestring }';

$this->assertGraphQLEquals($query, [
'data' => [
'simplestring' => 'You got this!'
]
]);
});
}

/**
* Test camel case query converter
*
Expand Down