Skip to content

Commit 9dc64aa

Browse files
author
Mikk Mihkel Nurges
committed
Merge branch 'master' into develop
2 parents a6e3521 + dd1a5af commit 9dc64aa

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/Rebing/GraphQL/GraphQL.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ public function schema($schema = null)
3333
$this->type($name);
3434
}
3535

36-
$schemaName = is_string($schema) ? $schema : config('graphql.default_schema', 'default');
37-
38-
if (!is_array($schema) && !isset($this->schemas[$schemaName])) {
39-
throw new SchemaNotFound('Type '.$schemaName.' not found.');
40-
}
41-
42-
$schema = is_array($schema) ? $schema:$this->schemas[$schemaName];
36+
$schema = $this->getSchemaConfiguration($schema);
4337

4438
$schemaQuery = array_get($schema, 'query', []);
4539
$schemaMutation = array_get($schema, 'mutation', []);
@@ -69,7 +63,7 @@ public function schema($schema = null)
6963
$mutation = $this->objectType($schemaMutation, [
7064
'name' => 'Mutation'
7165
]);
72-
66+
7367
$subscription = $this->objectType($schemaSubscription, [
7468
'name' => 'Subscription'
7569
]);
@@ -336,4 +330,15 @@ public static function routeNameTransformer ($name, $schemaParameterPattern, $qu
336330

337331
return $routeName ?: preg_replace($schemaParameterPattern, '{' . $name . '}', $queryRoute);
338332
}
333+
334+
protected function getSchemaConfiguration($schema)
335+
{
336+
$schemaName = is_string($schema) ? $schema : config('graphql.default_schema', 'default');
337+
338+
if (!is_array($schema) && !isset($this->schemas[$schemaName])) {
339+
throw new SchemaNotFound('Type ' . $schemaName . ' not found.');
340+
}
341+
342+
return is_array($schema) ? $schema : $this->schemas[$schemaName];
343+
}
339344
}

src/Rebing/GraphQL/Support/Field.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use GraphQL\Type\Definition\InputObjectType;
1010
use GraphQL\Type\Definition\ListOfType;
1111
use GraphQL\Type\Definition\WrappingType;
12+
use GraphQL\Type\Definition\NonNull;
1213

1314
class Field extends Fluent {
1415

@@ -93,6 +94,11 @@ public function inferRulesFromType($type, $prefix, $resolutionArguments)
9394
{
9495
$rules = [];
9596

97+
// make sure we are dealing with the actual type
98+
if ($type instanceof NonNull) {
99+
$type = $type->getWrappedType();
100+
}
101+
96102
// if it is an array type, add an array validation component
97103
if ($type instanceof ListOfType) {
98104
$prefix = "{$prefix}.*";

0 commit comments

Comments
 (0)