Description
I'm trying to use multiple schema.graphql as is in issue #500, but I got these errors:
Type "Mutation" already exists in the schema. It cannot also be defined in this type definition.
Type "Query" already exists in the schema. It cannot also be defined in this type definition.
I'm using the following code:
use GraphQL\Language\Parser;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Schema;
use GraphQL\Utils\SchemaExtender;
function buildSchema() {
$schema = new Schema(config: [
'query' => new ObjectType(config: ['name' => 'Query', 'fields' => []]),
'mutation' => new ObjectType(config: ['name' => 'Mutation', 'fields' => []]),
]);
$schemaFiles = [
__DIR__ . '/' . '../GraphQl/schema.graphql',
__DIR__ . '/' . '../../Domains/Authors/schema.graphql',
__DIR__ . '/' . '../../Domains/Books/schema.graphql',
];
$sources = array_map(callback: 'file_get_contents', array: $schemaFiles);
$extensionSource = implode(separator: "\n", array: $sources);
$ast = Parser::parse(source: $extensionSource);
return SchemaExtender::extend(schema: $schema, documentAST: $ast);
}
Version
PHP 8.3.2
webonyx/graphql-php 15.9.1
Description
I'm trying to use multiple schema.graphql as is in issue #500, but I got these errors:
I'm using the following code:
Version
PHP 8.3.2
webonyx/graphql-php 15.9.1