Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW: Compliance with new SchemaBuilder signature #331

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/GraphQL/Plugins/VersionedDataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,20 @@ public function getIdentifier(): string

/**
* @param Schema $schema
* @param array $config
* @throws SchemaBuilderException
*/
public static function updateSchema(Schema $schema): void
public static function updateSchema(Schema $schema, array $config = []): void
{
$schema->addModelbyClassName(Member::class);
// Hack.. we can't add a plugin within a plugin, so we have to add sort
// and pagination manually. This requires ensuring the sort types are added
// to the schema (most of the time this is redundant)
if (!$schema->getType('SortDirection')) {
AbstractQuerySortPlugin::updateSchema($schema);
AbstractQuerySortPlugin::updateSchema($schema, $config);
}
if (!$schema->getType('PageInfo')) {
PaginationPlugin::updateSchema($schema);
PaginationPlugin::updateSchema($schema, $config);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/php/GraphQL/Plugins/VersionedDataObjectPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testPluginAddsVersionedFields()
$schema = new Schema('test', $config);
$schema->addModel($type);
$plugin = new VersionedDataObject();
$plugin->updateSchema($schema);
$plugin->updateSchema($schema, []);
$this->assertInstanceOf(ModelType::class, $schema->getModelByClassName(Member::class));

$plugin->apply($type, $schema);
Expand Down Expand Up @@ -96,7 +96,7 @@ public function testPluginDoesntAddVersionedFieldsToUnversionedObjects()
$schema = new Schema('test', $config);
$schema->addModel($type);
$plugin = new VersionedDataObject();
$plugin->updateSchema($schema);
$plugin->updateSchema($schema, []);

$plugin->apply($type, $schema);
$type = $schema->getType('FakeVersion');
Expand Down