ayimdomnic / GraphQl-L5.3 by ayimdomnic

Facebook GraphQl for Laravel developers
13
3
3
Package Data
Maintainer Username: ayimdomnic
Maintainer Contact: Ayimdomnic@statuscreative.co.ke (Ayimdomnic)
Package Create Date: 2016-08-27
Package Last Update: 2023-04-17
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-04-27 03:01:06
Package Statistics
Total Downloads: 13
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 3
Total Watchers: 3
Total Forks: 0
Total Open Issues: 1

GraphQl-L5.3 StyleCI Build Status

After the Developer Workshop in Nairobi, I have resolved to Move from Rest to GraphQL, This is a package to assit me with the same as I develop may laravel APIs

#Requirements

  1. PHP 5.6 and Above
  2. Laravel 5.3

#Instalation

  1. composer require ayimdomnic/graph-ql-l5.3
  2. add Ayimdomnic\GraphQl\GraphQlServiceProvider::class, to config/app
  3. add 'GraphQl' => 'Ayimdomnic\GraphQl\Helper\Facade\GraphQl', to the Facades
  4. publish php artisan vendor:publish

#Usage

#Creating a Query(#creating-a-query)


	namespace App\GraphQl\Type;
	
	use GraphQL\Type\Definition\Type;
	use Ayimdomnic\GraphQl\Helper\Type as GraphQLType;
    
    class UserType extends GraphQLType {
        
        protected $attributes = [
			'name' => 'User',
			'description' => 'A user'
		];
		
		public function fields()
		{
			return [
				'id' => [
					'type' => Type::nonNull(Type::string()),
					'description' => 'The id of the user'
				],
				'email' => [
					'type' => Type::string(),
					'description' => 'The email of user'
				]
			];
		}
			
			
		#########If you want to resolve the field yourself, you can declare a method
		###################with the following format resolve[FIELD_NAME]Field()
		protected function resolveEmailField($root, $args)
		{
			return strtolower($root->email);
		}
        
    }

Creating a Mutation