Skip to content

Instantly share code, notes, and snippets.

@kevinvdburgt
Created September 21, 2017 12:47
Show Gist options
  • Save kevinvdburgt/cc00d59ab12ee3f2233e6f87d9d351d5 to your computer and use it in GitHub Desktop.
Save kevinvdburgt/cc00d59ab12ee3f2233e6f87d9d351d5 to your computer and use it in GitHub Desktop.
PHP GraphQL
<?php
namespace App\GraphQL\Query\General;
use Folklore\GraphQL\Support\Query;
use GraphQL\Type\Definition\ResolveInfo;
use GraphQL\Type\Definition\Type;
use GraphQL;
class Test extends Query
{
protected $attributes = [
'name' => 'Test',
'description' => 'A query'
];
public function type()
{
return Type::listOf(GraphQL::type('Test'));
}
public function args()
{
return [
];
}
public function resolve($root, $args, $context, ResolveInfo $info)
{
return [];
}
}
<?php
namespace App\GraphQL\Type\General;
use GraphQL\Type\Definition\Type;
use Folklore\GraphQL\Support\Type as BaseType;
use GraphQL;
class Test extends BaseType
{
protected $attributes = [
'name' => 'Test',
'description' => 'A type'
];
public function fields()
{
return [
'name' => [
'type' => Type::string(),
],
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment