GraphQLBundle
GraphQLBundle copied to clipboard
Inject schema extensions to SchemaBuilder via DI
the ValidatorExtension is binding to SchemaBuilder statically, can we Inject schema extensions to SchemaBuilder via DI?
I see, currently we can add custom schema extension via the Events::PRE_EXECUTOR event
private function preExecute(
Schema $schema,
?string $requestString,
\ArrayObject $contextValue,
$rootValue = null,
?array $variableValue = null,
?string $operationName = null
): ExecutorArgumentsEvent {
$this->dispatcher->dispatch(
new ExecutorContextEvent($contextValue),
Events::EXECUTOR_CONTEXT
);
return $this->dispatcher->dispatch(
ExecutorArgumentsEvent::create($schema, $requestString, $contextValue, $rootValue, $variableValue, $operationName),
Events::PRE_EXECUTOR
);
}
@mcg-web , the schema name is absent in ExecutorArgumentsEvent, can we also pass schema name to it ? or keep the schemName in the initial contextValue.
$executorArgumentsEvent = $this->preExecute(
$this->getSchema($schemaName),
$request[ParserInterface::PARAM_QUERY] ?? null,
new \ArrayObject(['schema' => $schemaName]),
$rootValue,
$request[ParserInterface::PARAM_VARIABLES],
$request[ParserInterface::PARAM_OPERATION_NAME] ?? null
);
I think the first option is better, in nature, it should be in the event.