Skip to content

Commit a74b570

Browse files
authored
Merge pull request #2181 from sroze/only-exposes-the-mutations-if-any
[GraphQL] Only exposes the mutations if any
2 parents f727d59 + 93c24ee commit a74b570

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/GraphQl/Type/SchemaBuilder.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,21 @@ public function getSchema(): Schema
9292
}
9393
}
9494

95-
return new Schema([
95+
$schema = [
9696
'query' => new ObjectType([
9797
'name' => 'Query',
9898
'fields' => $queryFields,
9999
]),
100-
'mutation' => new ObjectType([
100+
];
101+
102+
if ($mutationFields) {
103+
$schema['mutation'] = new ObjectType([
101104
'name' => 'Mutation',
102105
'fields' => $mutationFields,
103-
]),
104-
]);
106+
]);
107+
}
108+
109+
return new Schema($schema);
105110
}
106111

107112
private function getNodeInterface(): InterfaceType

0 commit comments

Comments
 (0)