PHP code example of overblog / graphql-php-generator
1. Go to this page and download the library: Download overblog/graphql-php-generator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
overblog / graphql-php-generator example snippets
$loader = hema;
use Overblog\GraphQLGenerator\Generator\TypeGenerator;
use Symfony\Component\ExpressionLanguage\Expression;
$configs = [
'Character' => [
'type' => 'interface',
'config' => [
'description' => new Expression('\'A character\' ~ \' in the Star Wars Trilogy\''),
'fields' => [
'id' => ['type' => 'String!', 'description' => 'The id of the character.'],
'name' => ['type' => 'String', 'description' => 'The name of the character.'],
'friends' => ['type' => '[Character]', 'description' => 'The friends of the character.'],
'appearsIn' => ['type' => '[Episode]', 'description' => 'Which movies they appear in.'],
],
'resolveType' => 'Overblog\\GraphQLGenerator\\Tests\\Resolver::resolveType',
],
],
/*...*/
'Query' => [
'type' => 'object',
'config' => [
'description' => 'A humanoid creature in the Star Wars universe or a faction in the Star Wars saga.',
'fields' => [
'hero' => [
'type' => 'Character',
'args' => [
'episode' => [
'type' => 'Episode',
'description' => 'If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.',
],
],
'resolve' => ['Overblog\\GraphQLGenerator\\Tests\\Resolver', 'getHero'],
],
],
],
/*...*/
],
];
$typeGenerator = new TypeGenerator('\\My\\Schema\\NP');
$classesMap = $typeGenerator->generateClasses($configs, __DIR__ . '/cache/types');
$loader->addClassMap($classesMap);
$schema = new Schema(\My\Schema\NP\QueryType::getInstance());
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.