Open
Description
Hey!
I'm currently playing around with a custom schema builder, that allows registering classes that extend the schema and eventually create a cacheable DocumentNode. It is working pretty well, my current solution looks like this:
/**
* @return DocumentNode
* @throws \GraphQL\Error\Error
* @throws \GraphQL\Error\SyntaxError
*/
public function buildCacheableSchema() : DocumentNode {
$schema = BuildSchema::build(self::BASE_SCHEMA);
foreach($this->extenders as $extender) {
if($extension = $extender->extend($schema)) {
$schema = SchemaExtender::extend($schema, Parser::parse($extender->extend($schema)));
}
}
return Parser::parse(SchemaPrinter::doPrint($schema));
}
However, I am facing the problem, that custom directives get lost during doPrint, because of the implementation of SchemaPrinter::printField which only includes deprecated directive .
Now my question consists of two parts:
-
Is there a better solution to get the DocumentNode from a Schema, besides doing parse(doPrint(schema))?
-
And if this actually is the best solution to do this, how do I get my custom directives into the final schema?
Thank you!