-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from moufmouf/no_query_mutation
Adding placeholder when there are no queries or no mutations
- Loading branch information
Showing
6 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ language: php | |
php: | ||
- 7.1 | ||
- 7.2 | ||
- 7.3 | ||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace TheCodingMachine\GraphQL\Controllers; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class SchemaTest extends AbstractQueryProviderTest | ||
{ | ||
|
||
public function testEmptyQuery() | ||
{ | ||
$queryProvider = new class implements QueryProviderInterface { | ||
public function getQueries(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function getMutations(): array | ||
{ | ||
return []; | ||
} | ||
}; | ||
|
||
$schema = new Schema($queryProvider, $this->getTypeMapper(), $this->getTypeResolver()); | ||
|
||
$fields = $schema->getQueryType()->getFields(); | ||
$this->assertArrayHasKey('dummyQuery', $fields); | ||
$resolve = $fields['dummyQuery']->resolveFn; | ||
$this->assertSame('This is a placeholder query. Please create a query using the @Query annotation.', $resolve()); | ||
|
||
$fields = $schema->getMutationType()->getFields(); | ||
$this->assertArrayHasKey('dummyMutation', $fields); | ||
$resolve = $fields['dummyMutation']->resolveFn; | ||
$this->assertSame('This is a placeholder mutation. Please create a mutation using the @Mutation annotation.', $resolve()); | ||
} | ||
} |