Skip to content

Commit

Permalink
Fix a bug where querying for Marix Blocks using the GraphQL API would…
Browse files Browse the repository at this point in the history
… not work.
  • Loading branch information
andris-sevcenko committed Sep 17, 2019
1 parent 5c816dc commit f4b60b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Fixed a bug where the "Update all" button was missing on the updates page. ([#4938](https://github.com/craftcms/cms/issues/4938))
- Fixed a bug where the “Updating search indexes” job could fail when updating search indexes for a Matrix block that contained a relational field.
- Fixed a bug where it was impossible to query for entries using author id with the GraphQL API.
- Fixed a bug where querying for Marix Blocks using the GraphQL API would not work.

## 3.3.3 - 2019-09-12

Expand Down
11 changes: 11 additions & 0 deletions src/services/Gql.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,17 @@ public function getSchemaDef(GqlSchema $schema = null, $prebuildSchema = false):
'directives' => $this->_loadGqlDirectives(),
];

// For some reason, matrix types need to be explicitly defined, too,
// otherwise it will complain on querying matrix blocks
$typeGeneratorClass = MatrixBlockInterface::getTypeGenerator();

foreach ($typeGeneratorClass::generateTypes() as $type) {
$schemaConfig['types'][] = $type;
}

// TODO fire an event to allow modifying the $schemConfig.
// At least one use-case being adding workaround like for Matrix above.

// If we're not required to pre-build the schema the relevant GraphQL types will be added to the Schema
// as the query is being resolved thanks to the magic of lazy-loading, so we needn't worry.
if (!$prebuildSchema) {
Expand Down

0 comments on commit f4b60b6

Please sign in to comment.