Skip to content
This repository has been archived by the owner on Mar 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #10 from nuwave/develop
Browse files Browse the repository at this point in the history
Merge develop branch
  • Loading branch information
chrissm79 committed Mar 12, 2016
2 parents 03b6c7b + aa32636 commit dd42543
Show file tree
Hide file tree
Showing 55 changed files with 4,057 additions and 695 deletions.
80 changes: 30 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,63 @@
# laravel-graphql-relay
# laravel-grapql-relay #

## Documentation currently under development
Use Facebook [GraphQL](http://facebook.github.io/graphql/) with [React Relay](https://facebook.github.io/relay/). This package extends graphql-php to work with Laravel and is currently **a work in progress**. You can reference what specifications GraphQL needs to provide to work with Relay in the [documentation](https://facebook.github.io/relay/docs/graphql-relay-specification.html#content).

Use Facebook [GraphQL](http://facebook.github.io/graphql/) with [React Relay](https://facebook.github.io/relay/). This package is used alongside [laravel-graphql](https://github.com/Folkloreatelier/laravel-graphql) and is currently **a work in progress**. You can reference what specifications GraphQL needs to provide to work with Relay in the [documentation](https://facebook.github.io/relay/docs/graphql-relay-specification.html#content).
Although this package no longer depends on [laraval-graphql](https://github.com/Folkloreatelier/laravel-graphql), it laid the foundation for this package which likely wouldn't exist without it. It is also a great alternative if you are using GraphQL w/o support for Relay.

## Installation
Because this package is still in the early stages, breaking changes will occur. We will keep the documentation updated with the current release. Please feel free to contribute, PR are absolutely welcome!

### Installation ###

You must then modify your composer.json file and run composer update to include the latest version of the package in your project.

```json
```php
"require": {
"nuwave/laravel-graphql-relay": "0.2.*"
"nuwave/laravel-graphql-relay": "0.3.*"
}
```

Or you can use the ```composer require``` command from your terminal.
Or you can use the composer require command from your terminal.

```json
```
composer require nuwave/laravel-graphql-relay
```

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

```php
Nuwave\Relay\ServiceProvider::class
```
Nuwave\Relay\LaravelServiceProvider::class
```

Add the Relay facade to your ```app/config.php``` file
Add the Relay & GraphQL facade to your app/config.php file

```php
```
'GraphQL' => Nuwave\Relay\Facades\GraphQL::class,
'Relay' => Nuwave\Relay\Facades\Relay::class,
```

Publish the configuration file

```php
php artisan vendor:publish --provider="Nuwave\Relay\ServiceProvider"
```
php artisan vendor:publish --provider="Nuwave\Relay\LaravelServiceProvider"
```

Add your Mutations, Queries and Types to the ```config/relay.php``` file
Create a ```schema.php``` file and add the path to the config

```php
// Example:

return [
'schema' => function () {
// Added by default
Relay::group(['namespace' => 'Nuwave\\Relay'], function () {
Relay::group(['namespace' => 'Node'], function () {
Relay::query('node', 'NodeQuery');
Relay::type('node', 'NodeType');
});

Relay::type('pageInfo', 'Types\\PageInfoType');
});

// Your mutations, queries and types
Relay::group(['namespace' => 'App\\Http\\GraphQL'], function () {
Relay::group(['namespace' => 'Mutations'], function () {
Relay::mutation('createUser', 'CreateUserMutation');
});

Relay::group(['namespace' => 'Queries', function () {
Relay::query('userQuery', 'UserQuery');
});

Relay::group(['namespace' => 'Types'], function () {
Relay::type('user', 'UserType');
Relay::type('event', 'EventType');
});
});
}
];
```
// config/relay.php
// ...
'schema' => [
'path' => 'Http/schema.php',
'output' => null,
],
```

To generate a ```schema.json``` file (used with the [Babel Relay Plugin](https://facebook.github.io/relay/docs/guides-babel-plugin.html#content))
To generate a ```schema.json``` file (used with the Babel Relay Plugin):

```php
```
php artisan relay:schema
```

For additional documentation, please read the [Wiki](https://github.com/nuwave/laravel-graphql-relay/wiki/1.-GraphQL-and-Relay)
*You can customize the output path in the ```relay.php``` config file under ```schema.output```*

For additional documentation, look through the docs folder or read the Wiki.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
}
},
"require": {
"folklore/graphql": "0.*",
"illuminate/console": "5.*"
"webonyx/graphql-php": "~0.5",
"illuminate/console": "5.*",
"doctrine/dbal": "^2.5"
}
}
56 changes: 37 additions & 19 deletions config/config.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
<?php
/*
|--------------------------------------------------------------------------
| Schema File
|--------------------------------------------------------------------------
|
| You can utilize this file to register all of you GraphQL schma queries
| and mutations. You can group collections together by namespace or middlware.
|
*/

return [
'schema' => function () {
Relay::group(['namespace' => 'Nuwave\\Relay'], function () {
Relay::group(['namespace' => 'Node'], function () {
Relay::query('node', 'NodeQuery');
Relay::type('node', 'NodeType');
});

Relay::type('pageInfo', 'Types\\PageInfoType');
});
/*
|--------------------------------------------------------------------------
| Namespace registry
|--------------------------------------------------------------------------
|
| This package provides a set of commands to make it easy for you to
| create new parts in your GraphQL schema. Change these values to
| match the namespaces you'd like each piece to be created in.
|
*/

// Additional Queries, Mutations and Types...
}
'namespaces' => [
'mutations' => 'App\\GraphQL\\Mutations',
'queries' => 'App\\GraphQL\\Queries',
'types' => 'App\\GraphQL\\Types',
'fields' => 'App\\GraphQL\\Fields',
],

/*
|--------------------------------------------------------------------------
| Schema declaration
|--------------------------------------------------------------------------
|
| This is a path that points to where your Relay schema is located
| relative to the app path. You should define your entire Relay
| schema in this file. Declare any Relay queries, mutations,
| and types here instead of laravel-graphql config file.
|
*/

'schema' => [
'path' => null,
'output' => null,
],

'controller' => 'Nuwave\Relay\Http\Controllers\LaravelController@query',
'model_path' => 'App\\Models',
'camel_case' => false,
];
52 changes: 52 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
## Configuration ##

When publishing the configuration, the package will create a ```relay.php``` file in your ```config``` folder.

### Namespaces ###

```php
'namespaces' => [
'mutations' => 'App\\GraphQL\\Mutations',
'queries' => 'App\\GraphQL\\Queries',
'types' => 'App\\GraphQL\\Types',
'fields' => 'App\\GraphQL\\Fields',
],
```

This package provides a list of commands that allows you to create Types, Mutations, Queries and Fields. You can specify the namespaces you would like the package to use when generating the files.

### Schema ###

```php
'schema' => [
'file' => 'Http/GraphQL/schema.php',
'output' => null,
]
```

** File **

Set the location of your schema file. (A schema is similar to your routes.php file and defines your Types, Mutations and Queries for GraphQL. Read More)

** Output **

This is the location where your generated ```schema.json``` will be created/updated. (This json file is used by the [Babel Relay Plugin](https://facebook.github.io/relay/docs/guides-babel-plugin.html#content)).

### Eloquent ###

```php
'eloquent' => [
'path' => 'App\\Models',
'camel_case' => false
]
```

** Path **

The package allows you to create Types based off of your Eloquent models. You can use the ```path``` to define the namespace of your models or you can use the full namespace when generating Types from the console (Read More).

** Camel Case **

Camel casing is quite common in javascript, but Laravel's database column naming convention is snake case. If you would like your Eloquent model's generated fields converted to camel case, you may set this to true.

*This works great with the [Eloquence package](https://github.com/kirkbushell/eloquence).*
63 changes: 63 additions & 0 deletions docs/Overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# laravel-grapql-relay #

Use Facebook [GraphQL](http://facebook.github.io/graphql/) with [React Relay](https://facebook.github.io/relay/). This package extends graphql-php to work with Laravel and is currently **a work in progress**. You can reference what specifications GraphQL needs to provide to work with Relay in the [documentation](https://facebook.github.io/relay/docs/graphql-relay-specification.html#content).

Although this package no longer depends on [laraval-graphql](https://github.com/Folkloreatelier/laravel-graphql), it laid the foundation for this package which likely wouldn't exist without it. It is also a great alternative if you are using GraphQL w/o support for Relay.

Because this package is still in the early stages, breaking changes will occur. We will keep the documentation updated with the current release. Please feel free to contribute, PR are absolutely welcome!

### Installation ###

You must then modify your composer.json file and run composer update to include the latest version of the package in your project.

```php
"require": {
"nuwave/laravel-graphql-relay": "0.3.*"
}
```

Or you can use the composer require command from your terminal.

```
composer require nuwave/laravel-graphql-relay
```

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

```
Nuwave\Relay\LaravelServiceProvider::class
```

Add the Relay & GraphQL facade to your app/config.php file

```
'GraphQL' => Nuwave\Relay\Facades\GraphQL::class,
'Relay' => Nuwave\Relay\Facades\Relay::class,
```

Publish the configuration file

```
php artisan vendor:publish --provider="Nuwave\Relay\LaravelServiceProvider"
```

Create a ```schema.php``` file and add the path to the config

```
// config/relay.php
// ...
'schema' => [
'path' => 'Http/schema.php',
'output' => null,
],
```

To generate a ```schema.json``` file (used with the Babel Relay Plugin):

```
php artisan relay:schema
```

*You can customize the output path in the ```relay.php``` config file under ```schema.output```*

For additional documentation, look through the docs folder or read the Wiki.
Loading

0 comments on commit dd42543

Please sign in to comment.