New to Graphql, using webonyx/graphql-php.
What benefit is there to defining my schema with class style definitions vs. graphql's provided syntax?
I have a basic working example using class style schema defs as following:
use MyApp\Type\MediaType;
use MyApp\TypeRegistry;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
class MusicType extends ObjectType {
public function __construct() {
$config = [
'fields' => [
'id' => Type::id(),
'name' => Type::String(),
'url' => Type::String(),
'dateStart' => Type::String(),
'dateEnd' => Type::String()
],
'interfaces' => [
TypeRegistry::media(),
TypeRegistry::dateRestricted(),
]
];
parent::__construct($config);
}
}
However, I find defining the schema this way to be clunky, with the only real benefit I can see being that I can define my resolvers in the same location as the schema.
Using the schema.graphqls syntax looks cleaner and would be more easily ported to other server-side languages...
type Music implements Media {
id: ID!
name: String!
url: String!
dateStart: String
dateEnd: String
}
What benefit is there to defining my schema with class style definitions vs. graphql's provided syntax?