Download the PHP package fandogh/graphql without Composer

On this page you can find all versions of the php package fandogh/graphql. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package graphql

Laravel GraphQL

Use Facebook GraphQL with Laravel 5. 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.

Installation

Dependencies:

Installation:

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

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

or

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

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

5- Publish the configuration file

6- Review the configuration file

Usage

Advanced Usage

Creating a query

First you need to create a type.

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

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

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.

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

Or using the GraphQL facade

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

For example, if you use homestead:

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.

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

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

Or using the GraphQL facade

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

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:

Alternatively you can define rules with each args

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.

Advanced usage

Query Variables

GraphQL offer you the possibility to use variables in your query so you don't need to "hardcode" value. This is done like that:

When you query the GraphQL endpoint, you can pass a params parameter.

Custom field

You can also define a field as a class if you want to reuse it in multiple types.

You can then use it in your type declaration

Eager loading relationships

The third argument passed to a query's resolve method is an instance of GraphQL\Type\Definition\ResolveInfo which you can use to retrieve keys from the request. The following is an example of using this information to eager load related Eloquent models.

Your Query would look like

Your Type for User would look like

At this point we have a profile and a post type as expected for any model

Lastly your query would look like, if using Homestead

For example, if you use homestead:


All versions of graphql with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
illuminate/support Version 5.*
webonyx/graphql-php Version ~0.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package fandogh/graphql contains the following files

Loading the files please wait ....