Facebook GraphQL for Laravel 5. It supports Relay, eloquent models, validation and GraphiQL.

Overview

Laravel GraphQL


This package is no longuer maintained. Please use rebing/graphql-laravel or other Laravel GraphQL packages


Use Facebook GraphQL with Laravel 5 or Lumen. It is based on the PHP implementation here. You can find more information about GraphQL in the GraphQL Introduction on the React blog or you can read the GraphQL specifications. This is a work in progress.

This package is compatible with Eloquent model (or any other data source). See the example below.

Latest Stable Version Build Status Total Downloads


To use laravel-graphql with Relay, check the feature/relay branch.


Installation

Version 1.0 is released. If you are upgrading from older version, you can check Upgrade to 1.0.

Dependencies:

1- Require the package via Composer in your composer.json.

{
  "require": {
    "folklore/graphql": "~1.0.0"
  }
}

2- Run Composer to install or update the new requirement.

$ composer install

or

$ composer update

Laravel >= 5.5.x

1- Publish the configuration file

$ php artisan vendor:publish --provider="Folklore\GraphQL\ServiceProvider"

2- Review the configuration file

config/graphql.php

Laravel <= 5.4.x

1- Add the service provider to your config/app.php file

Folklore\GraphQL\ServiceProvider::class,

2- Add the facade to your config/app.php file

'GraphQL' => Folklore\GraphQL\Support\Facades\GraphQL::class,

3- Publish the configuration file

$ php artisan vendor:publish --provider="Folklore\GraphQL\ServiceProvider"

4- Review the configuration file

config/graphql.php

Lumen

1- Load the service provider in bootstrap/app.php

$app->register(Folklore\GraphQL\LumenServiceProvider::class);

2- For using the facade you have to uncomment the line $app->withFacades(); in bootstrap/app.php

After uncommenting this line you have the GraphQL facade enabled

$app->withFacades();

3- Publish the configuration file

$ php artisan graphql:publish

4- Load configuration file in bootstrap/app.php

Important: this command needs to be executed before the registration of the service provider

$app->configure('graphql');
...
$app->register(Folklore\GraphQL\LumenServiceProvider::class)

5- Review the configuration file

config/graphql.php

Documentation

Usage

Advanced Usage

Schemas

Starting from version 1.0, you can define multiple schemas. Having multiple schemas can be useful if, for example, you want an endpoint that is public and another one that needs authentication.

You can define multiple schemas in the config:

'schema' => 'default',

'schemas' => [
    'default' => [
        'query' => [
            //'users' => 'App\GraphQL\Query\UsersQuery'
        ],
        'mutation' => [
            //'updateUserEmail' => 'App\GraphQL\Query\UpdateUserEmailMutation'
        ]
    ],
    'secret' => [
        'query' => [
            //'users' => 'App\GraphQL\Query\UsersQuery'
        ],
        'mutation' => [
            //'updateUserEmail' => 'App\GraphQL\Query\UpdateUserEmailMutation'
        ]
    ]
]

Or you can add schema using the facade:

GraphQL::addSchema('secret', [
    'query' => [
        'users' => 'App\GraphQL\Query\UsersQuery'
    ],
    'mutation' => [
        'updateUserEmail' => 'App\GraphQL\Query\UpdateUserEmailMutation'
    ]
]);

Afterwards, you can build the schema using the facade:

// Will return the default schema defined by 'schema' in the config
$schema = GraphQL::schema();

// Will return the 'secret' schema
$schema = GraphQL::schema('secret');

// Will build a new schema
$schema = GraphQL::schema([
    'query' => [
        //'users' => 'App\GraphQL\Query\UsersQuery'
    ],
    'mutation' => [
        //'updateUserEmail' => 'App\GraphQL\Query\UpdateUserEmailMutation'
    ]
]);

Or you can request the endpoint for a specific schema

// Default schema
http://homestead.app/graphql?query=query+FetchUsers{users{id,email}}

// Secret schema
http://homestead.app/graphql/secret?query=query+FetchUsers{users{id,email}}

Creating a query

First you need to create a type.

namespace App\GraphQL\Type;

use GraphQL\Type\Definition\Type;
use Folklore\GraphQL\Support\Type as GraphQLType;

class UserType extends GraphQLType
{
    protected $attributes = [
        'name' => 'User',
        'description' => 'A user'
    ];

    /*
    * Uncomment following line to make the type input object.
    * http://graphql.org/learn/schema/#input-types
    */
    // protected $inputObject = true;

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

Add the type to the config/graphql.php configuration file

'types' => [
    'User' => 'App\GraphQL\Type\UserType'
]

You could also add the type with the GraphQL Facade, in a service provider for example.

GraphQL::addType('App\GraphQL\Type\UserType', 'User');

Then you need to define a query that returns this type (or a list). You can also specify arguments that you can use in the resolve method.

namespace App\GraphQL\Query;

use GraphQL;
use GraphQL\Type\Definition\Type;
use Folklore\GraphQL\Support\Query;
use App\User;

class UsersQuery extends Query
{
    protected $attributes = [
        'name' => 'users'
    ];

    public function type()
    {
        return Type::listOf(GraphQL::type('User'));
    }

    public function args()
    {
        return [
            'id' => ['name' => 'id', 'type' => Type::string()],
            'email' => ['name' => 'email', 'type' => Type::string()]
        ];
    }

    public function resolve($root, $args)
    {
        if (isset($args['id'])) {
            return User::where('id' , $args['id'])->get();
        } else if(isset($args['email'])) {
            return User::where('email', $args['email'])->get();
        } else {
            return User::all();
        }
    }
}

Add the query to the config/graphql.php configuration file

'schemas' => [
    'default' => [
        'query' => [
            'users' => 'App\GraphQL\Query\UsersQuery'
        ],
        // ...
    ]
]

And that's it. You should be able to query GraphQL with a request to the url /graphql (or anything you choose in your config). Try a GET request with the following query input

query FetchUsers {
  users {
    id
    email
  }
}

For example, if you use homestead:

http://homestead.app/graphql?query=query+FetchUsers{users{id,email}}

Creating a mutation

A mutation is like any other query, it accepts arguments (which will be used to do the mutation) and return an object of a certain type.

For example a mutation to update the password of a user. First you need to define the Mutation.

namespace App\GraphQL\Mutation;

use GraphQL;
use GraphQL\Type\Definition\Type;
use Folklore\GraphQL\Support\Mutation;
use App\User;

class UpdateUserPasswordMutation extends Mutation
{
    protected $attributes = [
        'name' => 'updateUserPassword'
    ];

    public function type()
    {
        return GraphQL::type('User');
    }

    public function args()
    {
        return [
            'id' => ['name' => 'id', 'type' => Type::nonNull(Type::string())],
            'password' => ['name' => 'password', 'type' => Type::nonNull(Type::string())]
        ];
    }

    public function resolve($root, $args)
    {
        $user = User::find($args['id']);

        if (!$user) {
            return null;
        }

        $user->password = bcrypt($args['password']);
        $user->save();

        return $user;
    }
}

As you can see in the resolve method, you use the arguments to update your model and return it.

You then add the mutation to the config/graphql.php configuration file

'schema' => [
    'default' => [
        'mutation' => [
            'updateUserPassword' => 'App\GraphQL\Mutation\UpdateUserPasswordMutation'
        ],
        // ...
    ]
]

You should then be able to use the following query on your endpoint to do the mutation.

mutation users {
  updateUserPassword(id: "1", password: "newpassword") {
    id
    email
  }
}

if you use homestead:

http://homestead.app/graphql?query=mutation+users{updateUserPassword(id: "1", password: "newpassword"){id,email}}

Adding validation to mutation

It is possible to add validation rules to mutation. It uses the laravel Validator to performs validation against the args.

When creating a mutation, you can add a method to define the validation rules that apply by doing the following:

namespace App\GraphQL\Mutation;

use GraphQL;
use GraphQL\Type\Definition\Type;
use Folklore\GraphQL\Support\Mutation;
use App\User;

class UpdateUserEmailMutation extends Mutation
{
    protected $attributes = [
        'name' => 'UpdateUserEmail'
    ];

    public function type()
    {
        return GraphQL::type('User');
    }

    public function args()
    {
        return [
            'id' => ['name' => 'id', 'type' => Type::string()],
            'email' => ['name' => 'email', 'type' => Type::string()]
        ];
    }

    public function rules()
    {
        return [
            'id' => ['required'],
            'email' => ['required', 'email']
        ];
    }

    public function resolve($root, $args)
    {
        $user = User::find($args['id']);

        if (!$user) {
            return null;
        }

        $user->email = $args['email'];
        $user->save();

        return $user;
    }
}

Alternatively you can define rules with each args

class UpdateUserEmailMutation extends Mutation
{
    //...

    public function args()
    {
        return [
            'id' => [
                'name' => 'id',
                'type' => Type::string(),
                'rules' => ['required']
            ],
            'email' => [
                'name' => 'email',
                'type' => Type::string(),
                'rules' => ['required', 'email']
            ]
        ];
    }

    //...
}

When you execute a mutation, it will returns the validation errors. Since GraphQL specifications define a certain format for errors, the validation errors messages are added to the error object as a extra validation attribute. To find the validation error, you should check for the error with a message equals to 'validation', then the validation attribute will contain the normal errors messages returned by the Laravel Validator.

{
  "data": {
    "updateUserEmail": null
  },
  "errors": [
    {
      "message": "validation",
      "locations": [
        {
          "line": 1,
          "column": 20
        }
      ],
      "validation": {
        "email": [
          "The email is invalid."
        ]
      }
    }
  ]
}
Comments
  • Added pagination type

    Added pagination type

    This should make pagination a bit easier, instead of creating a pagination type for each other type (#187) now simply use this in your Query:

    <?php
    
    namespace App\GraphQL\Query;
    
    use Folklore\GraphQL\Support\Query;
    use GraphQL\Type\Definition\ResolveInfo;
    use GraphQL\Type\Definition\Type;
    use GraphQL;
    
    use App\Models\User;
    
    class UsersQuery extends Query
    {
        protected $attributes = [
            'name' => 'UsersQuery',
            'description' => 'A query'
        ];
    
        public function type()
        {
            return GraphQL::paginate('User');
        }
    
        public function args()
        {
            return [
                'page' => [
                    'name' => 'page',
                    'type' => Type::int(),
                    'description' => 'Display a specific page',
                ],
                'limit' => [
                    'name' => 'limit',
                    'type' => Type::int(),
                    'description' => 'Limit the items per page',
                ],
            ];
        }
    
        public function resolve($root, $args, $context, ResolveInfo $info)
        {
            return User::paginate($args['limit'] ?? 20, ['*'], 'page', $args['page'] ?? 0);
        }
    }
    
    

    Example:

    Query:

    {
        users(page:1 limit:10) {
            data {
                id
            }
            total
            limit
            page
        }
    }
    

    results in:

    {
        "data": {
            "users": {
                "data": [
                    {
                        "id": "89734"
                    },
                    {
                        "id": "89735"
                    },
                    {
                        "id": "99009"
                    },
                    {
                        "id": "99010"
                    },
                    {
                        "id": "104032"
                    },
                    {
                        "id": "104033"
                    },
                    {
                        "id": "104034"
                    },
                    {
                        "id": "104035"
                    },
                    {
                        "id": "104036"
                    },
                    {
                        "id": "104037"
                    }
                ],
                "total": 22,
                "limit": 10,
                "page": 1
            }
        }
    }
    
    opened by kevinvdburgt 25
  • Add a command to generate a GraphiQL view and a route at /graphiql

    Add a command to generate a GraphiQL view and a route at /graphiql

    For me GraphiQL is one of the best features of GraphQL, so I tought I would share a command to automatically create a blade view and add a /graphiql route to your web.php route file. I used a CDN for all assets to have no added dependencies to the project.

    Thanks!

    opened by pelletiermaxime 16
  • Different middleware for different queries/mutations?

    Different middleware for different queries/mutations?

    How can I assign middlewares per query or mutation?

    I have some queries and mutations which are public, others which require auth, and others which require auth and a particular user privilege.

    opened by tremby 15
  • Added pagination with cursor info

    Added pagination with cursor info

    Created a new implementation of my previous pagination PR (#242).

    Example project: https://github.com/kevinvdburgt/laravel-graphql-example/blob/62daca1f6ebe5664afc01488a5b437ab7b6f32bf/app/GraphQL/Query/PostsQuery.php#L20

    screen shot 2018-03-04 at 20 51 59

    When using the pagination type, for example:

    public function type()
    {
        return GraphQL::pagination(GraphQL::type('Post'));
    }
    

    The library will create's a type PostPagination and a PaginationCursor type when it doesnt exists yet.

    opened by kevinvdburgt 13
  • Add support for caching

    Add support for caching

    Please add support for caching. With large database structures this GraphQL library will get very slow.

    A manual caching inside the resolve() function is not working because the GraphQL library.

    opened by pschaub 12
  • How do I use a custom scalar type?

    How do I use a custom scalar type?

    I want to use a custom scalar type, in particular an extension of IntType which handles datetimes, transmitting them as unix timestamps.

    The following is the class I'm attempting to use.

    <?php
    
    namespace App\GraphQL\Type;
    
    use Carbon\Carbon;
    use GraphQL\Language\AST\IntValueNode;
    use GraphQL\Type\Definition\IntType;
    
    class TimestampType extends IntType
    {
        /**
         * @var string
         */
        public $name = "Timestamp";
    
        /**
         * @var string
         */
        public $description = "A UNIX timestamp represented as an integer";
    
        /**
         * Serializes an internal value to include in a response.
         *
         * @param mixed $value
         * @return mixed
         */
        public function serialize($value)
        {
            return $this->toTimestamp($value);
        }
    
        /**
         * Parses an externally provided value (query variable) to use as an input
         *
         * @param mixed $value
         * @return mixed
         */
        public function parseValue($value)
        {
            return $this->toTimestamp($value);
        }
    
        /**
         * Parses an externally provided literal value (hardcoded in GraphQL query)
         * to use as an input
         *
         * @param \GraphQL\Language\AST\Node $valueNode
         * @return mixed
         */
        public function parseLiteral($ast)
        {
            if ($ast instanceof IntValueNode) {
                $val = (int) $ast->value;
                if ($ast->value === (string) $val && self::MIN_INT <= $val && $val <= self::MAX_INT) {
                    return Carbon::createFromTimestamp($val);
                }
            }
            return null;
        }
    
        /**
         * Turn a value into a timestamp.
         *
         * @param mixed $value Could be anything the Carbon constructor can parse
         * (Carbon, DateTime, string, ...) or a timestamp integer
         *
         * @return int
         */
        protected function toTimestamp($value)
        {
            if (is_int($value)) {
                return $value;
            }
            return (new Carbon($value))->getTimestamp();
        }
    }
    

    I've added this to types in the GraphQL configuration:

        'types' => [
            ...
            App\GraphQL\Type\TimestampType::class,
            ...
        ],
    

    But when attempting to use it via app('graphql')->type('Timestamp') I'm getting Call to undefined method App\GraphQL\Type\TimestampType::toType().

    I feel like I'm approaching this all wrong -- please point me in the right direction.

    opened by tremby 12
  • Cannot use PHPUnit tests and Lumen with Facades

    Cannot use PHPUnit tests and Lumen with Facades

    Hey there.

    I'm building a project with Lumen and GraphQL and everything is working fine, except when I try to test with PHPUnit.

    PHPUnit 5.7.9 by Sebastian Bergmann and contributors.
    
    E                                                                   1 / 1 (100%)
    
    Time: 771 ms, Memory: 6.00MB
    
    There was 1 error:
    
    1) ExampleTest::testExample
    ErrorException: Cannot declare class GraphQL, because the name is already in use
    
    /var/www/vendor/folklore/graphql/src/Folklore/GraphQL/LumenServiceProvider.php:57
    /var/www/vendor/folklore/graphql/src/Folklore/GraphQL/ServiceProvider.php:160
    /var/www/vendor/laravel/lumen-framework/src/Application.php:172
    /var/www/bootstrap/app.php:86
    /var/www/tests/TestCase.php:12
    /var/www/vendor/laravel/lumen-framework/src/Testing/TestCase.php:56
    /var/www/vendor/laravel/lumen-framework/src/Testing/TestCase.php:67
    

    It only works when I disable Facades.

    opened by vitor-mariano 12
  • Added per schema middleware

    Added per schema middleware

    Added a feature to apply middleware per schema.

    /**
     * Any middleware for a specific 'graphql' schema
     */
    'middleware_schema' => [
        'default' => ['auth.basic'],
    ],
    

    Possible solution for #191

    opened by kevinvdburgt 11
  • Bug with Interfaces mapping to objects?

    Bug with Interfaces mapping to objects?

    While trying to use interfaces in my own project, I ran into a few issues. First off, as with queries and mutations, a sample query which returns an InterfaceType would probably make this a lot easier for anyone new.

    Interface

    use GraphQL;
    use GraphQL\Type\Definition\Type;
    use Folklore\GraphQL\Support\InterfaceType;
    use Illuminate\Support\Facades\Log;
    
    class BogusInterface extends InterfaceType {
      protected $attributes = [
          'name' => 'Bogus',
          'description' => 'Bogus interface.',
      ];
    
      public function fields() {
        return [
            'id' => [
                'type' => Type::nonNull(Type::int()),
                'description' => 'The id of the bogus thing',
            ],
        ];
      }
    
      public function resolveType($root) {
        // Use the resolveType to resolve the Type which is implemented trough this interface
    
        Log::error($root);
        $type = $root['type'];
        if ($type === 'BogusText') {
          return GraphQL::type('BogusText');
        } else if  ($type === 'BogusNum') {
          return GraphQL::type('BogusNum');
        }
      }
    }
    

    Implementor A

    use GraphQL;
    use Folklore\GraphQL\Support\Type as GraphQLType;
    use GraphQL\Type\Definition\Type;
    
    class BogusTextType extends GraphQLType {
    
      protected $attributes = [
          'name' => 'BogusText',
          'description' => 'A BogusNum.'
      ];
    
      public function fields() {
        return [
            'id' => [
                'type' => Type::nonNull(Type::int()),
                'description' => 'The id of the resource result',
            ],
            'text' => [
                'type' => Type::nonNull(Type::string()),
                'description' => 'The title of the resource result',
            ],
        ];
      }
    
      public function interfaces() {
        return [
            GraphQL::type('Bogus')
        ];
      }
    }
    

    Implementor B

    use GraphQL;
    use Folklore\GraphQL\Support\Type as GraphQLType;
    use GraphQL\Type\Definition\Type;
    
    class BogusNumType extends GraphQLType {
    
      protected $attributes = [
          'name' => 'BogusNum',
          'description' => 'A BogusNum.'
      ];
    
      public function fields() {
        return [
            'id' => [
                'type' => Type::nonNull(Type::int()),
                'description' => 'The id of the resource result',
            ],
            'num' => [
                'type' => Type::nonNull(Type::int()),
                'description' => 'The title of the resource result',
            ],
        ];
      }
    
      public function interfaces() {
        return [
            GraphQL::type('Bogus')
        ];
      }
    }
    

    Query

    use Dream\Models\BogusNum;
    use Dream\Models\BogusText;
    use GraphQL;
    use GraphQL\Type\Definition\Type;
    use GraphQL\Type\Definition\ResolveInfo;
    use Folklore\GraphQL\Support\Query;
    
    class BogusQuery extends Query {
      protected $attributes = [
          'name' => 'bogus',
      ];
    
      public function __construct($attributes = []) {
        parent::__construct($attributes);
      }
    
      public function type() {
        return Type::listOf(GraphQL::type('Bogus'));
      }
    
      public function args() {
        return [
            'term'         => ['name' => 'term', 'type' => Type::string()],
        ];
      }
    
      public function resolve($root, $args, $context, ResolveInfo $info) {
        $results = [];
    
        $result = new BogusText();
        $result->id = 1;
        $result->text = 'foo';
        $results[] = $result;
    
        $result = new BogusNum();
        $result->id = 1;
        $result->text = 'foo';
        $results[] = $result;
    
        $result = new BogusText();
        $result->id = 2;
        $result->num = 42;
        $results[] = $result;
    
    
        return $results;
      }
    }
    

    Objects mapped to graphql types

    class BogusText {
      public $id;
    
      public $text;
    }
    
    class BogusNum {
      public $id;
    
      public $num;
    }
    

    This will generate a valid schema, and appears to be correct from a graphiql docs perspective. When I try to run the following query though, I get an error for each result, Object of class Dream\\Models\\BogusNum could not be converted to string

    {
      bogus(term: "an") {
        id
        ... on BogusText {
          text
        }
        ... on BogusNum {
           num
        }
      }
    }
    

    Am I missing something here? Either way, it would nice if this functionality were documented end to end.

    opened by kaamoss 11
  • Eager Loading & iterable error

    Eager Loading & iterable error

    I have followed the Readme for eager loading

    public function resolve($root, $args, ResolveInfo $info)
    {
        $fields = $info->getFieldSelection($depth = 3);
    
        $users = User::query();
    
        foreach ($fields as $field => $keys) {
            if ($field === 'team') {
                $users->with('team');
            }
        }
    
        return $users->get();
    }
    

    This query runs successfully in my app.

    [2015-11-12 11:22:46] View Logs.INFO: select * from `teams` where `teams`.`id` in (?, ?, ?) [1,2,3] []
    

    And in my UserType class I have the following in the fields function

    'team' => [
        'type' => Type::listOf(GraphQL::type('team')),
        'description' => 'The users team',
    ]
    

    I am getting the following error:

    User Error: expected iterable, but did not find one.
    

    If I add a resolve function to the team array it works but I then loose the eager loading functionality:

    'team' => [
        'type' => Type::listOf(GraphQL::type('team')),
        'description' => 'The users team',
        'resolve' => function($data, $args) {
             return $data->team()->get();
        }
    ]
    
    
    opened by joshhornby 11
  • Customizing the validation error messages

    Customizing the validation error messages

    Fixes #117

    If needed, you may use custom error messages for validation instead of the defaults. You can customize the error messages used by the ShouldValidate trait by overriding the validationErrorMessages method.

    <?php
    
    namespace App\GraphQL\Mutation\Auth;
    
    use Folklore\GraphQL\Support\Mutation;
    use GraphQL\Type\Definition\Type;
    use GraphQL;
    
    class LoginMutation extends Mutation
    {
       protected $attributes = [
            'name' => 'LoginMutation',
            'description' => 'Login user with Email and password',
        ];
    
        public function type()
        {
            return GraphQL::type('IssueToken');
        }
    
        public function args()
        {
            return [
                'input' => [
                    'name' => 'input',
                    'type' => Type::nonNull(GraphQL::type('LoginUserInput')),
                ],
            ];
        }
    
        public function rules()
        {
            return [
                'input.login' => 'required|string|email|max:255',
                'input.password' => 'required|string|min:6',
            ];
        }
    
        public function resolve($root, $args, $context)
        {
            return $this->login($args);
        }
    
        /**
         * Return an array of custom validation messages.
         *
         * @return array
         */
        public function validationErrorMessages()
        {
            return [
                'input.login.email' => 'The login must be a valid e-mail address!',
                'input.password.min' => 'The password must be at least 6 characters!',
            ];
        }
    }
     
    
    opened by mohammad-fouladgar 10
  • Not compatible with PHP 7.3

    Not compatible with PHP 7.3

    The latest tagged release as well as master depends on webonxy/graphql ~0.10.2.

    This is quite an old version and is not compatible with PHP 7.3 due this somewhere in the webonxy library: PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?

    This code fragment does not even exist in the latest webonxy release, so it's clear only an upgrade of webonyx can make 7.3 compatibility.

    opened by mfn 1
  • How to pass meta data to the Type?

    How to pass meta data to the Type?

    The underlying library supports metadata in for the types, https://webonyx.github.io/graphql-php/type-system/object-types/#custom-metadata, how do I use this?

    opened by edalzell 1
  • default (abstract) queries and mutations

    default (abstract) queries and mutations "crud"

    So I am wondering, is there a way to generate the queries and mutations, and maybe even the types. Mainly the mutations and queries are all the same. queries( get 1 type, get all types) mutations( createType, updateType, deleteType) For example in a blog, the Article and Comments are quite repetative in creating the same queries and mutations. Even more idealitair is that of creating a type out of an eloquent model. Just pass an array of models in which you want the default 'crud' operations to be active. There of course are some cases in which this does not cover the usecase, EG authentication in which you want to write a 'custom' type ,query and mutation.

    I hope it already exists, or if someone could explain why this isn't already a feature.

    Great respect to all working on this repo, maybe I could help on this feature if it does not already exists.

    opened by adminfriso 0
  • Create contracts Type to use in all Graph type

    Create contracts Type to use in all Graph type

    I thought that to add types (Timestamp, PaginationMeta, Links etc ..) in a simple and intuitive way was to create a class that has a static method for each type and that calls it by passing the value of the query in the "resolve" so that can be processed independently. This allows me to call these methods staunchly and makes it easy to use them in multiple types. What do you think?

    UserType.php with TimestampType for data query=query+FetchUsers{users{id,name,timestamp{created_at,updated_at}}} usertype

    TypeRegistry all method that return Contracts type with resolve() function typeregistry

    TimestampType is type of time, you can add field to fields array timestamptype

    schermata del 2018-10-30 10-10-00

    opened by FabrizioCafolla 0
Owner
Folklore Inc.
Digital craftsmen dedicated to the Web.
Folklore Inc.
Laravel wrapper for the Facebook Graph PHP 8 SDK

Laravel Facebook Graph SDK Installation Getting started with Laravel Facebook Graph is easy - first, install the package via composer composer require

Joel Butcher 44 Dec 8, 2022
HTTP Requestor: Package for a client request that supports you to make an external service request easily and with fast usage.

HttpRequestor from Patienceman HTTP Requestor: Package for a client request that supports you to make an external service request easily and with fast

Manirabona Patience 2 Aug 26, 2022
🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.

Telegram Bot API - PHP SDK Telegram Bot PHP SDK lets you develop Telegram Bots in PHP easily! Supports Laravel out of the box. Telegram Bot API is an

Irfaq Syed 2.5k Jan 6, 2023
PHP GitHub Sponsors is a package that integrates directly with the GitHub Sponsors GraphQL API.

PHP GitHub Sponsors PHP GitHub Sponsors is a package that integrates directly with the GitHub Sponsors GraphQL API. Using it, you can easily check if

GitHub PHP 101 Nov 2, 2022
Amazon SNS message validation for PHP

The Amazon SNS Message Validator for PHP library allows you to validate that incoming HTTP(S) POST messages are valid Amazon SNS notifications.

Amazon Web Services 192 Dec 7, 2022
Laravel Package for 1APP. Learn how to integrate our APIs to build a web or mobile integration to send and accept payments for your application and businesses.

1APP Laravel Library Learn how to integrate our APIs to build a web or mobile integration to accept payments, make payment of Bills and as well custom

O'Bounce Technologies 4 Jul 25, 2022
The Universal Device Detection library will parse any User Agent and detect the browser, operating system, device used (desktop, tablet, mobile, tv, cars, console, etc.), brand and model.

DeviceDetector Code Status Description The Universal Device Detection library that parses User Agents and detects devices (desktop, tablet, mobile, tv

Matomo Analytics 2.4k Jan 9, 2023
Toxiproxy PHP Client - Toxiproxy makes it easy and trivial to test network conditions, for example low-bandwidth and high-latency situations

Toxiproxy makes it easy and trivial to test network conditions, for example low-bandwidth and high-latency situations. toxiproxy-php-client includes everything needed to get started with configuring Toxiproxy upstream connection and listen endpoints.

Adrian Parker 29 Jun 24, 2022
A Laravel package to retrieve pageviews and other data from Google Analytics

Retrieve data from Google Analytics Using this package you can easily retrieve data from Google Analytics. Here are a few examples of the provided met

Spatie 2.8k Jan 7, 2023
A simple API documentation package for Laravel using OpenAPI and Redoc

Laravel Redoc Easily publish your API documentation using your OpenAPI document in your Laravel Application. Installation You can install this package

Steve McDougall 15 Dec 27, 2022
This package is a simple API laravel wrapper for Pokemontcg with a sleek Model design for API routes and authentication.

This package is a simple API laravel wrapper for Pokemontcg with a sleek Model design for API routes and authentication.

Daniel Henze 3 Aug 29, 2022
Laravel ClickHouse adds CH client integration, generation & execution of ClickHouse database migrations to the Laravel application.

Laravel ClickHouse Introduction Laravel ClickHouse database integration. This package includes generation and execution of the ClickHouse database mig

cybercog 11 Dec 20, 2022
A simple PHP GitHub API client, Object Oriented, tested and documented.

PHP GitHub API A simple Object Oriented wrapper for GitHub API, written with PHP. Uses GitHub API v3 & supports GitHub API v4. The object API (v3) is

KNP Labs 2k Jan 7, 2023
A PHP library for communicating with the Twilio REST API and generating TwiML.

twilio-php The default branch name for this repository has been changed to main as of 07/27/2020. Documentation The documentation for the Twilio API c

Twilio 1.4k Jan 2, 2023
PHP library to use IOTA REST API to help node management and tangle queries

iota.php About PHP library to use IOTA REST API to help node management and tangle queries. Please be aware that this library is in an early developme

IOTA Community 45 Dec 13, 2022
A PHP class for querying the Twitter API and rendering tweets as an HTML list

TweetPHP A PHP class for querying the Twitter API and rendering tweets as an HTML list. Features Works with Twitter API v1.1 Tweets are cached to avoi

Jonathan Nicol 151 Nov 25, 2022
playSMS is a web interface for SMS gateways and bulk SMS services

README Latest development release is playSMS version 1.4.4-beta4 Latest stable release is playSMS version 1.4.3 Official project website: https://play

playSMS 662 Dec 31, 2022
DigitalOcean API v2 client for Symfony and API Platform

DigitalOcean Bundle for Symfony and API Platform DunglasDigitalOceanBundle allows using the DigitalOcean API from your Symfony and API Platform projec

Kévin Dunglas 25 Jul 27, 2022