-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
179 additions
and
3 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
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,34 @@ | ||
<?php | ||
|
||
use GraphQL\Type\Definition\Type; | ||
use Rebing\GraphQL\Support\Type as GraphQLType; | ||
|
||
class ExampleFilterInputType extends GraphQLType | ||
{ | ||
protected $inputObject = true; | ||
|
||
protected $attributes = [ | ||
'name' => 'ExampleFilterInput', | ||
'description' => 'A nested filter input with self reference' | ||
]; | ||
|
||
public function fields() | ||
{ | ||
return [ | ||
'AND' => [ | ||
'type' => Type::listOf(Type::nonNull(GraphQL::type('ExampleFilterInput'))), | ||
'description' => 'List of self references' | ||
], | ||
'test' => [ | ||
'type' => Type::String(), | ||
'description' => 'Test field filter' | ||
], | ||
// This field can trigger an infinite recursion | ||
// in case recursion in Field.getRules() is not handled correctly | ||
'parent' => [ | ||
'type' => GraphQL::type('ExampleFilterInput'), | ||
'description' => 'Self reference' | ||
] | ||
]; | ||
} | ||
} |
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,44 @@ | ||
<?php | ||
|
||
use GraphQL\Type\Definition\Type; | ||
use Rebing\GraphQL\Support\Query; | ||
|
||
class ExamplesFilteredQuery extends Query | ||
{ | ||
protected $attributes = [ | ||
'name' => 'Filtered examples' | ||
]; | ||
|
||
public function type() | ||
{ | ||
return Type::listOf(GraphQL::type('Example')); | ||
} | ||
|
||
public function args() | ||
{ | ||
return [ | ||
'filter' => [ | ||
'name' => 'filter', | ||
'type' => GraphQL::type('ExampleFilterInput') | ||
] | ||
]; | ||
} | ||
|
||
public function resolve($root, $args) | ||
{ | ||
$data = include(__DIR__.'/data.php'); | ||
$result = []; | ||
|
||
if (isset($args['filter'])) { | ||
if(isset($args['filter']['test'])) { | ||
foreach($data as $item) { | ||
if($item['test'] == $args['filter']['test']) { | ||
$result[] = $item; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return $result; | ||
} | ||
} |
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