Skip to content

Commit 32c3a7b

Browse files
committed
make mutation optional for Schema
1 parent 63229d7 commit 32c3a7b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/Schemas/Schema.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ class Schema
2121
* @param GraphQLObjectType $queryType
2222
* @param GraphQLObjectType $mutationType
2323
*/
24-
public function __construct(?GraphQLObjectType $queryType, ?GraphQLObjectType $mutationType, ?array $directives = null)
24+
public function __construct(?GraphQLObjectType $queryType, ?GraphQLObjectType $mutationType = null, ?array $directives = null)
2525
{
2626
$this->queryType = $queryType;
27-
$this->mutationType = $mutationType;
27+
$this->mutationType = $mutationType ?? null;
2828
$this->directives = $directives ?? [];
2929

3030
$allReferencedTypes = [];
@@ -42,7 +42,7 @@ public function __construct(?GraphQLObjectType $queryType, ?GraphQLObjectType $m
4242
//TODO: check for custom directives (see: https://github.com/graphql/graphql-js/blob/5ed55b89d526c637eeb9c440715367eec8a2adec/src/type/schema.js#L190)
4343

4444
$__Schema = null;
45-
require_once __DIR__ .'/../Introspection/Introspection.php';
45+
require_once __DIR__ . '/../Introspection/Introspection.php';
4646
$this->collectReferencedTypes($__Schema, $allReferencedTypes);
4747

4848
// build type map
@@ -62,11 +62,11 @@ public function __construct(?GraphQLObjectType $queryType, ?GraphQLObjectType $m
6262
$this->typeMap[$typeName] = $namedType;
6363

6464
// generate $this->implementationsMap
65-
if($namedType->isInterfaceType()){
66-
foreach($namedType->getInterfaces() as $iface){
67-
if($iface->isInterfaceType()){
65+
if ($namedType->isInterfaceType()) {
66+
foreach ($namedType->getInterfaces() as $iface) {
67+
if ($iface->isInterfaceType()) {
6868
$implementations = $this->implementationsMap[$iface->getName()] ?? null;
69-
if($implementations === null){
69+
if ($implementations === null) {
7070
$this->implementationsMap[$iface->getName()] = [
7171
"objects" => [],
7272
"interfaces" => []
@@ -75,11 +75,11 @@ public function __construct(?GraphQLObjectType $queryType, ?GraphQLObjectType $m
7575
$this->implementationsMap[$iface->getName()]["interfaces"][] = $namedType;
7676
}
7777
}
78-
}else if($namedType->isObjectType()){
79-
foreach($namedType->getInterfaces() as $iface){
80-
if($iface->isInterfaceType()){
78+
} else if ($namedType->isObjectType()) {
79+
foreach ($namedType->getInterfaces() as $iface) {
80+
if ($iface->isInterfaceType()) {
8181
$implementations = $this->implementationsMap[$iface->getName()] ?? null;
82-
if($implementations === null){
82+
if ($implementations === null) {
8383
$this->implementationsMap[$iface->getName()] = [
8484
"objects" => [],
8585
"interfaces" => []
@@ -143,7 +143,7 @@ public function getType(string $name): ?GraphQLType
143143
public function isSubType(GraphQLAbstractType $abstractType, GraphQLType $maybeSubType)
144144
{
145145
$map = $this->subTypeMap[$abstractType->getName()] ?? null;
146-
if($map === null) {
146+
if ($map === null) {
147147
$map = [];
148148
if ($abstractType->isUnionType()) {
149149
foreach ($abstractType->getTypes() as $type) {

0 commit comments

Comments
 (0)