There's some difference in building test schemas vs building real schemas which results in an error when building the below schema in tests which is perfectly fine and valid with normal runtime execution. This discrepancy is making it impossible to test https://github.com/silverstripe/silverstripe-graphql/pull/538 and could mean we are getting some false positives in existing tests.
Steps to reproduce
Create the following models.yml file in both vendor/silverstripe/graphql/tests/Schema/_testRecursiveSortSchemaCanBuild/models.yml and app/_graphql/models.yml:
Add this method in vendor/silverstripe/graphql/tests/Schema/IntegrationTest.php:
public function testRecursiveSortSchemaCanBuild()
{
// We're just testing that there's no exception on schema generation.
$this->expectNotToPerformAssertions();
$dir = '_' . __FUNCTION__;
$this->createSchema(new TestSchemaBuilder([$dir]));
}
Finally, compare the results of running sake dev/graphql/build (which will run fine without any errors) vs running the new test method via PHPUnit.
The PHPUnit test will fail with this exception:
SilverStripe\GraphQL\Schema\Exception\SchemaBuilderException: Failed to apply plugin SilverStripe\GraphQL\Schema\DataObject\Plugin\QuerySort to readPermissions. Got error "Could not find field "id" on type "PermissionConnection". If it is a custom filter field, you will need to provide a resolver function in the "resolver" config for that field along with an explicit type."
There's some difference in building test schemas vs building real schemas which results in an error when building the below schema in tests which is perfectly fine and valid with normal runtime execution. This discrepancy is making it impossible to test https://github.com/silverstripe/silverstripe-graphql/pull/538 and could mean we are getting some false positives in existing tests.
Steps to reproduce
Create the following
models.yml
file in bothvendor/silverstripe/graphql/tests/Schema/_testRecursiveSortSchemaCanBuild/models.yml
andapp/_graphql/models.yml
:Add this config to
app/_config/graphql.yml
:Add this method in
vendor/silverstripe/graphql/tests/Schema/IntegrationTest.php
:Finally, compare the results of running
sake dev/graphql/build
(which will run fine without any errors) vs running the new test method via PHPUnit. The PHPUnit test will fail with this exception: