PHP code example of ayimdomnic / graph-ql-l5.3

1. Go to this page and download the library: Download ayimdomnic/graph-ql-l5.3 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/ */

    

ayimdomnic / graph-ql-l5.3 example snippets



	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);
		}
        
    }